Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to trap COM instantiation
Message
From
31/07/2003 13:32:16
 
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00815490
Message ID:
00815512
Views:
9
I'm not sure about the scope problem, but I was under the impression that a return statement in a catch block is a syntax error.

Alan

>Hello All,
>
>How do you check and trap for the instantiation of a COM component when you are unsure of whether or not a user will have the component library installed?
>
>In VFP I can do:
>
>TRY
>    *-- Create zipper object
>    loZipper = CREATEOBJECT( "XceedSoftware.XceedZip.4" )
>CATCH
>
>ENDTRY
>IF TYPE("loZipper") <> "O"
>    * Could not create zip object, probably don't have the Xceed components installed
>    MESSAGEBOX("Please check to make sure you have the Xceed Zip Compression Library installed", ;
>        0 + 16,"Error: Missing Required Files")
>    RETURN .F.
>ENDIF
>
>
>However, if I try to do the following in C#:
>
>try
>{
>    XceedZipLib.XceedZipClass 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;
>}
>
>loZipper.PreservePaths = false;
>loZipper.FilesToProcess = ...
>
>
>
>I get an error saying that "The type or namespace name 'type/namespace' could not be found (are you missing a using directive or an assembly reference?)" when I try to do anything with the loZipper object. If remove the try-catch, everything is fine. Why does the scope change in the try-catch?
>
>So... How should I be testing for loZipper creation?
>
>
>Thanks,
>
>- Brian
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform