How can I write a Batch file for setting paths & registering a .NET DLL?
Hi everybody, I love what u guys are doing here, keep it up people!
Errr... I'm new to .NET development though i'm a veteran developer in Java and PHP. I recently wrote a VB.NET DLL for a friend who does VBA apps with MS ACCESS, and he needs to use it on multiple systems.
Those who have created interop DLLs know the hell u have to go through to register & set it up to work (all the GAC, SN and REGASM stuff). I don't want my friend to go through all this trouble each time he wants to run his app on a new System and refernce my DLL.
So, here comes my problem. I know a batch can file can solve this problem, but I've never written a batch file before. I need help from anyone who can write a batch file to set the path of the EXECs [gacutil.exe, regasm.exe], and then run the regasm.exe tool with the '/tld:' switch to create the .tld file & also run gacutil.exe to register it in the GAC. I want him to copy the .DLL, .BAT and .SNK files to Windows\System32 folder then just click the batch file to do all the registering.
Somebody please help!
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
This is a basic way to register a .dll with the help of batch file. Type this in a text file and save it as updatebatchfiles.bat
Regsvr32.exe c:\windows\system32\myfile1.Dll
Regsvr32.exe c:\windows\system32\myfile2.Dll
Regsvr32.exe c:\windows\system32\myfile3.Dll
If you search this forum you will find plenty of examples on batch files.
Hope this puts you in the right direction....
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
Hey koolsid, thanks for ur help, but that would only work for COM components written in VB6 or versions before .NET; trust me, i know i went through some DLL hell trying to use RegSvr32 to register it before.
My actual problem here is not how to register the DLL, but how to create a batch file to do that with one click.
Thanks again!
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
Try this batch file:
%windir%\Microsoft.NET\Framework\v2.0.50727\regasm.exe "VB.net dll path"
If you keep the .bat file and dlls in the same directory then u need to just specify VB.net dll name instead off full path.
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
Hey, Deepak thanks, that helped a lot, but i wonder if there's an environment variable that .NET sets on installation that holds the full or relative path of the current .NET framework installation like the '%windir%' bit you used.
I'd like it to be a one-time script that works even if there's a different version of .NET.
Thank you so much
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
Unfortunately Microsoft has not provided any environment variable which holds .NET Framework path. Better you create different batch files for each version.
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
Why aren't you creating a deployment application with a merge module?
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
Quote:
Originally Posted by Deepak Sakpal
Unfortunately Microsoft has not provided any environment variable which holds .NET Framework path. Better you create different batch files for each version.
Hey thanx again Deepak; i guess i'll have to resort to multiple batch files then.
Re: How can I write a Batch file for setting paths & registering a .NET DLL?
mendhak, what is a merge module, & how do i create one?