PDA

View Full Version : Run the GAC to register an assembly



jkirkerx
09-11-2011, 02:53 PM
I need to run the gacutil.exe to register an assembly.

I'm new to this, and I'm looking for a pointer in the right direction. I'm not really sure what I'm doing here and sort of frustrated.

I wanted to do something simple in vb, but I ended up trying something more complex, in which I wrote a c++ dll, and registered it in Custom Actions. I'm having trouble with the application entry point, and not really sure if my dll works. I wrote a simple program that write a text file in the root of C so I know it fired.

Is it possible for me to write a vb script, or vb dll instead of the c++ dll, so I can just get it done and move forward?

I do need to get the location of gacutil.exe and the location of the Microsoft.Web.Administrator.dll that I placed in SupportFiles Disk 1

jkirkerx
09-11-2011, 05:25 PM
OK, I got it to work, at least I can load the dll and fire the function now, and I think I have it loaded in the right place or sequence.

Now I just need to figure out how to pass the locations of DISK1 where my gacutil.exe is, and figure out how to use the values below.

So I have in my Function Signature
Handle - Constant - MsiHandle
STRING - Constant - [SRCDIR]
STRING - Constant - [SUPPORTDIR]
STRING - Constant - [INSTALLDIR]

I wrote a test file to the C:\ root, and wrote lines in my c++ function

UINT __stdcall _install_Microsoft_Web_Administrator( MSIHANDLE hInstall, char* SRCDIR, char* SUPPORTDIR, char* INSTALLDIR ) {
int exit_Code;

std::ofstream myfile;
myfile.open("C:\\example.txt");

myfile << "Writing this to a file.\n";
myfile << "SourceDIR=" << SRCDIR << "\n";
myfile << "SupportDIR=" << SUPPORTDIR << "\n";
myfile << "InstallDIR=" << INSTALLDIR << "\n";

myfile.close();

exit_Code = 0;
return exit_Code;

}

but this is what I got in my text file
Writing this to a file.
SourceDIR=[SRCDIR]
SupportDIR=[SUPPORTDIR]
InstallDIR=[INSTALLDIR]

joshstechnij
09-12-2011, 01:00 PM
Please note that it is our understanding that gacutil.exe is not a file that is eligible for redistribution (see http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx). Installing assemblies in the GAC should normally be performed through a component in an MSI package (such as with Basic MSI projects).

If you would still like to use a C++ DLL for a custom action to perform this operation, we would recommend using an MSI style DLL instead of the "standard" DLL type. MSI DLL actions accept a single parameter (a handle to the install session) that can be used to retrieve any properties needed with an API such as MsiGetProperty. Such DLLs are simpler to work with and maintain and have no issues that could be encountered with the overhead from standard DLLs.

jkirkerx
09-13-2011, 11:22 AM
I'm not familiar with a msi dll. I ended using a win32 console dll and made 1 variable for the msiHandle or handler.

I'm new to this, this is my first c++ program since school 20 years ago. I used Visual Studio 2010 Pro to make the app.

Bummer on the gacutil. Perhaps I should create 2 versions of my setup wizard, 1 for Vista/7 and 1 for XP. I used the Microsoft.Web.Administration to support the program I wrote in .Net to create websites in IIS7, and it bombs in XP because the assembly is not registered in the global cache.

hmm

Edit:

Thanks for the heads on on the link, I'll use that method instead.