39

I have created a class library for a workflow on a local machine and build that. I moved the complete solution to a Tridion server and tried to register the assembly in the server using regasm.exe tool as below:

C:\User\XYZ\Desktop\>RegAsm \codebase F:\Workflow\WorkflowHandler/bin/debug/WorkflowHandler.dll

I got the following error:

failed to load 'F:\Workflow\WorkflowHandler/bin/debug/WorkflowHandler.dll ' because it is not a valid .NET Assembly.

My server details:

64-bit, Windows Server 2008 R2 Enterprise, and .NET Framework 4 installed.

leppie
  • 115,091
  • 17
  • 196
  • 297
Jey
  • 2,137
  • 4
  • 22
  • 40
  • Could it be a 32- vs. 64-bit issue? Could it be the remote system doesn't have .NET 4.0 installed? – reuben Jul 04 '12 at 04:19
  • its an 64 bit server, and .net 4 installed, and i built the class library in framework 4 – Jey Jul 04 '12 at 04:31
  • You know your slash on "\codebase" is going the wrong way, right? It should be "/codebase" (without quotes). – reuben Jul 04 '12 at 04:34
  • yes, i tired like this also (F:\Workflow> RegAsm /codebase F:/workflow/workflowhandler/bin/debug/workflowhandler.dll) ,still getting the same error. and tried to change the "/" into "\", still same error. and tried to give the dll path between "", still the same error. in my class library solution, i have create the strong name using the solution properties and in assemblyinfo.cs file i had set com visible = "true" apart from that havent to any. – Jey Jul 04 '12 at 04:56

2 Answers2

77

Are you sure you have the right RegAsm in your path since you're calling it by exe name only without specifying the full path? You must call the right version of RegAsm for it to work, i.e 32 or 64-bit version of .NET 4.

Try specifying the full path:

c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe /codebase F:\Workflow\WorkflowHandler\bin\debug\WorkflowHandler.dll

or

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe /codebase F:\Workflow\WorkflowHandler\bin\debug\WorkflowHandler.dll

Also I noticed that in the path to your assembly you had some / characters instead of \. Make sure you're putting in the correct path.

Damir Arh
  • 17,637
  • 2
  • 45
  • 83
  • Thanks a lot, i was using the wrong RegAsm.exe, now i am able to registered successfully. How can i check whether the registerd assembly is there in right place? whether it is really registerd or not? – Jey Jul 04 '12 at 05:02
  • @user1428019 If it didn't fail, it should be registered successfully. If you have Visual Studio registered on the machine you could try adding a reference to a COM component and see if it is listed there. Otherwise you could write a VBScript and try instantiating the COM component there. – Damir Arh Jul 04 '12 at 07:25
  • Thanks. I was using the Framework64 RegAsm on a 64bit machine, when I used the 32bit one it worked. Must be a 32 bit dll :) – Peter Morris Sep 13 '12 at 10:50
  • 1
    Brilliant! I had launched the wrong Visual Studio Command Prompt, if I had explicitly referenced the .NET 2.0 regasm it would have worked first time. Thanks. – Jay Imerman Oct 30 '13 at 02:25
2

I'll expand on the accepted answer with my solution.

First, I ran into issues with "AnyCPU" (I have to interop with COM, hence my reason for doing this), so I limit platform to x86 and x64. I wanted it to register the component as part of the build, so I did this as a post build event:

if $(PlatformName) == x64 (
    set RegAsm=$(MSBuildFrameworkToolsPath64)regasm.exe
) else (
    set RegAsm=$(MSBuildFrameworkToolsPath)regasm.exe
)

echo Creating TypeLib
"%RegAsm%" /tlb "$(TargetPath)"
echo Registering Component
"%RegAsm%" "$(TargetPath)"

Note: This probably won't work for ia64. If you've got to make this work for one of those, you've got bigger problems than this, though. :-)

Jamie
  • 1,754
  • 16
  • 34