Distributing Application
-
I've written an export type C# application which formats and saves an excel spreadsheet. I added a reference to excel using the .net ide and all seems to work fine on my pc. When I copy the exe (including Excel, VBIDE and Office dlls) to the target pc the application seems to run (and create the target file), but the file it creates contains about 10 characters, all of which are jibberish. The target PC contains the same version of excel as mine, does anyone knowwhat I need to do to make the app work? Do I need to register any of the dlls? Thanks for any help Jason
-
I've written an export type C# application which formats and saves an excel spreadsheet. I added a reference to excel using the .net ide and all seems to work fine on my pc. When I copy the exe (including Excel, VBIDE and Office dlls) to the target pc the application seems to run (and create the target file), but the file it creates contains about 10 characters, all of which are jibberish. The target PC contains the same version of excel as mine, does anyone knowwhat I need to do to make the app work? Do I need to register any of the dlls? Thanks for any help Jason
No, you do not need to register the DLLs (the only assemblies you would register are those that contain CCWs, or COM-Callable Wrappers - the interop assemblies you're using are RCW, or Runtime-Callable Wrappers, to COM servers already registered). Instead of create the interop assemblies yourself, use the PIAs (Primary Interop Assemblies) from Microsoft - the official assemblies created by them. You can download them for Office XP (just search for Office PIAs on http://msdn.microsoft.com[^]) or install them with Office 2003 Professional as ".NET Framework Support" or something like that. Make sure that these assemblies are either deployed to the same directory as the assemblies you've created (and pay attention to code access security policies if they're not running on the local machine), or install them into the GAC (Global Assembly Cache) using gacutil.exe, ngen.exe (also pre-JITs the IL), drag and drop them to %WINDIR%\assembly, or using an installer like Windows Installer (for which VS.NET has basic installer projects).
Microsoft MVP, Visual C# My Articles
-
No, you do not need to register the DLLs (the only assemblies you would register are those that contain CCWs, or COM-Callable Wrappers - the interop assemblies you're using are RCW, or Runtime-Callable Wrappers, to COM servers already registered). Instead of create the interop assemblies yourself, use the PIAs (Primary Interop Assemblies) from Microsoft - the official assemblies created by them. You can download them for Office XP (just search for Office PIAs on http://msdn.microsoft.com[^]) or install them with Office 2003 Professional as ".NET Framework Support" or something like that. Make sure that these assemblies are either deployed to the same directory as the assemblies you've created (and pay attention to code access security policies if they're not running on the local machine), or install them into the GAC (Global Assembly Cache) using gacutil.exe, ngen.exe (also pre-JITs the IL), drag and drop them to %WINDIR%\assembly, or using an installer like Windows Installer (for which VS.NET has basic installer projects).
Microsoft MVP, Visual C# My Articles
Thanks for the advice, I just about managed to follow it all! (maybe one day i'll increase from newbie status!) The version of office I am using is 2000, so I can't go down the PIA route. I think i'll create an installer for the app as I don't have direct access to the machine, it's an end user performing the install.