Tuesday, October 27, 2009

How to find Regasm.exe and use it in a .Bat file

I need to use RegAsm.exe to register several assemblies in a .bat file; however, since RegAsm.exe is not in the system path, it is difficult to just use like Regsvr32 which is always in the system path. I suppose the reason for this is that there can be multiple .NET Frameworks installed and you need to use the correct one.

You can use the WINDIR enviroment variable to get the root of the path. It will probably be something like:

C:\WINDOWS

You then need to add "\Microsft.NET\Framework\" to the path, and finally the path to the specific .NET Framework you are using:

SET fwpath="%windir%\Microsoft.NET\Framework\v2.0.50727"

%fwpath%\regasm.exe app.dll

How to pass TARGETDIR with CustomActionData and not get an Error

Maybe it is just me, but it seems like everything I need to do with an MSI setup is never as easy as it should be. Here is just an other example.

I need to pass the Target Directory for the installation to the InstallClass that I am using in the MSI Custom Actions (I have to do this because of other things in the MSI that don't work like they should). However, when I define the CustomActionData as:

/targetPath=[TARGETDIR]

or

/targetPath="[TARGETDIR]"


I get the following error:

Error 1001. Exception occurred while initializing the Installation:System.IO.FileNotFoundException


The solution I have found is to say this:

/targetPath="[TARGETDIR]\"

I found this info from the following post:

http://www.dotnet247.com/247reference/msgs/35/179584.aspx


I later found the Microsoft documentation on solving the problem:

http://msdn.microsoft.com/en-us/library/2w2fhwzz(VS.71).aspx

Thursday, October 22, 2009

Import an Excel File with VB.NET

Here is a simple solution for importing an Excel file into VB.NET using an OleDbConnection:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_22487951.html