-
Dec 15th, 2015, 05:16 AM
#1
Thread Starter
Addicted Member
How do you pass a "namespace.interface" as a parameter to a function?
Hi,
I'm trying to write a function to test if a dll I'm about to use is registered or not,. I've got lots of 3rd party dlls which I use which may not be registered, so I want to call a function, where I pass it the "namespace.interface" I'm about to use and the name of the dll to use if it needs to register it.
Here's my code for 1 dll which I'm trying to replace with my function, but I don't know how to pass "FitManager.CFitManager" into my function:
Code:
Dim processRegister_DLL As New Process
processRegister_DLL.StartInfo.UseShellExecute = False
processRegister_DLL.StartInfo.RedirectStandardOutput = True
processRegister_DLL.StartInfo.WindowStyle = ProcessWindowStyle.Normal
processRegister_DLL.StartInfo.CreateNoWindow = False
processRegister_DLL.StartInfo.FileName = Environment.SystemDirectory & "\regsvr32"
MsgBox("About to test FitManager.dll")
Try
Dim oFitManager_Test As New FitManager.CFitManager
oFitManager_Test = Nothing
MsgBox("FitManager.dll already registered")
Catch ex As Exception
MsgBox("FitManager.dll is not registered")
MsgBox("About to register FitManager.dll")
processRegister_DLL.StartInfo.Arguments = ".\FitManager.dll"
processRegister_DLL.Start()
processRegister_DLL.WaitForExit()
If processRegister_DLL.ExitCode <> 0 Then
MsgBox("Failed to Register FitManager.dll. Admin Rights are required to register a DLL")
Exit Sub
Else
MsgBox("FitManager.dll registered OK")
End If
End Try
-
Dec 15th, 2015, 07:41 AM
#2
Re: How do you pass a "namespace.interface" as a parameter to a function?
Just because something is a ".dll" doesn't mean it has to be registered. Only ActiveX DLLs would need to be registered. Since this is VB.NET code, I'm assuming that what you're tapping into is a .NET Assembly, which doesn't need to be registered. You can find out if the file exists, and if so, use reflection to load the assembly and then get a list of all the classes in it and test the results to make sure that "FitManager.CFitManager" exists.
-tg
-
Dec 15th, 2015, 10:36 AM
#3
Thread Starter
Addicted Member
Re: How do you pass a "namespace.interface" as a parameter to a function?
Originally Posted by techgnome
Just because something is a ".dll" doesn't mean it has to be registered. Only ActiveX DLLs would need to be registered. Since this is VB.NET code, I'm assuming that what you're tapping into is a .NET Assembly, which doesn't need to be registered. You can find out if the file exists, and if so, use reflection to load the assembly and then get a list of all the classes in it and test the results to make sure that "FitManager.CFitManager" exists.
-tg
I think the libraries are either vb6 or Fortran and my code crashes if they are not registered (but as you said I noticed that some of the newer dlls don't need registering). Under references, they are a mixture of COM or .NET and most of the .NET ones have interops. A while ago I tried to use reflection to load them but had problems - maybe because it was a COM dll. I forgot to mention that this is for a Winform app running on Windows 7. As I need to test if the dlls exist in several places I just wanted to write a function to do the test, but struggled passing the namespace.interface
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|