ADO DOT NET Posted April 24, 2007 Posted April 24, 2007 Hi everyone, My application needs outlook 2007 installed property to run. I mean I have used some COM components from outlook 2007 in my app. So if outlook is installed on the target system, my application won't have problem. Otherwise my app won't even start and will close with an error. I can check if outlook is installed on the system via registry. But the question is that my only way would be importing those COM dlls at runtime to my app. Is such thing possible in VB.NET 2005? Exactly like you add some COM component reference at design time to the application? In this way I can check first if outlook is installed then import those COM dlls to my app? Thanks. Quote
Administrators PlausiblyDamp Posted April 24, 2007 Administrators Posted April 24, 2007 Does your application crash even before the Outlook COM Classes are referenced or is it just failing to create the objects? If the object isn't registered then it should throw a trappable exception when it fails to create a valid instance - could you not simply catch this and notify the user? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ADO DOT NET Posted April 24, 2007 Author Posted April 24, 2007 It crashes only after I add those COM components! How can I catch those errors? Quote
Administrators PlausiblyDamp Posted April 25, 2007 Administrators Posted April 25, 2007 Is it crashing before you are using them in code though? Will the application run ok until it actually attempts to use the Outlook COM objects? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ADO DOT NET Posted April 27, 2007 Author Posted April 27, 2007 Thanks See the error I receive, if I press continue app loads but won't work! Quote
Administrators PlausiblyDamp Posted April 27, 2007 Administrators Posted April 27, 2007 That looks like it is at least running your application till it hits a line of code where you are trying to use the Outlook component (it is crashing in your Form_Load rather than earlier in the application). Try putting a Try ... Catch block around the code you are using to instantiate the outlook component - if an exception is raised then outlook probably isn't installed. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ADO DOT NET Posted April 27, 2007 Author Posted April 27, 2007 Is it possible to use DLLImport some thing like this:? <DllImport("*.dll", SetLastError:=True, CharSet:=CharSet.Auto)> Quote
Administrators PlausiblyDamp Posted April 27, 2007 Administrators Posted April 27, 2007 DLLImport is used to reference a normal (i.e. non COM) DLL and would be no help in this case. You should only be experiencing this problem when you attempt to use[/use] the component - simply running a program that references it will not be enough to cause a crash. Like I have said before simply wrap the call(s) to the component in a try catch block to catch the errors. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts