Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to trap COM instantiation
Message
 
To
31/07/2003 13:45:49
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00815490
Message ID:
00815605
Views:
7
This message has been marked as a message which has helped to the initial question of the thread.
XceedZipLib.XceedZipClass loZipper
try
{
loZipper = new XceedZipLib.XceedZipClass();
}
catch
{
MessageBox.Show("Please check to make sure you have the Xceed Zip Compression Library installed",
"Error: Missing Required Files", MessageBoxButtons.OK, MessageBoxIcon.Stop);

return false;
}

Is not the correct way because 1)Hide the others possible error 2)the construc is not in the scope. With try..any and object instantation:

Declare Object

Create Object
try
Accionts
catch
Manage Errors
finally
//not if the object is public or must be returned
Release Object/Close object
end

So i suggest:

Private function GetZip:XceedZipLib.XceedZipClass
loZipper as XceedZipLib.XceedZipClass

loZipper = new XceedZipLib.XceedZipClass()

return loZipper
End Function

funtion Main
loZipper as XceedZipLib.XceedZipClass

try
loZipper=GetZip()
...
catch
Please trap ONLY the creation error, never hide the others
end
End Function
The Life is Beautiful!

Programmer in
Delphi, VS.NET
MCP
Previous
Reply
Map
View

Click here to load this message in the networking platform