开发者

Regasm fails if an assembly depends on other assembly is not located in the same folder

Consider the following scenario:

I have two assemblies:

  • Assembly named A.dll located in folder Fold_A
  • Assembly named B.dll located in folder Fold_B

A.dll depends on B.dll and A is COM visible when I'm performing command:

regasm A.dll /codebase

It fails, but when B was copied into fold_a - the command succeeded.

Is there some way to perform without copying assemblies on which depends assembly to be registered (by regasm)?

There is already question related to the issue: Multiple search paths for assemblies not in the GAC when using开发者_Python百科 REGASM & COM


Well, yes, it is a problem when you register it but it will be a much larger problem when a client actually uses your COM server. A typical COM client will be unmanaged code, it isn't very practical to give it, say, a .config file to tell the CLR where to look for assembly B.

If you want this to work for any client without config then you ought to put B in the GAC. Which in general is the proper place for COM servers, DLL Hell is nothing to mess with when you use COM. Using the Assembly.AssemblyResolve event is probably not going to be practical but you could try by using a static class constructor to register the event handler. Hard coding the path to dependencies is questionable unless those folders are always related.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜