How to make C# COM DLL equivalent to ATL COM C++ -
hi trying develop com using c# , visual studio 2005
first did interface "csharpserver.cs"
<code> using system; using system.runtime.interopservices; namespace csharpserver { [comvisible(true)] [guid("dbe0e8c4-1c61-41f3-b6a4-4e2f353d3d05")] public interface imanagedinterface { int printhi(); } [comvisible(true)] [guid("c6659361-1625-4746-931c-36014b146679")] public class interfaceimplementation : imanagedinterface { public int printhi() { console.writeline("hello!"); return 33; } } } </code>
i compiled. output is: csharp_server.dll. after, did: regasm csharp_server.dll /tlb /codebase
output is:
... regasm : warning ra0000 : registering unsigned assembly /codebase can ca use assembly interfere other applications may installed on same computer. /codebase switch intended used signed assemblies. please give assembly strong name , re-register it. types registered ...
1ª question: have sign? how?
2ª question: removed author.
3ª question: can run "regasm" command prompt visual studio. if develop com component using c#, , distribute client, has have visual studio installed? if customer has installed delphi, , want use component, have install visual studio?
4ª inside visual studio c#, trying add com reference says:
a reference 'csharp_server' not added. activex type library 'xxx\csharp_server.tlb' exported .net assembly , cannot added reference. add reference .net assembly instead. in ". net reference". can not see component "csharp_server."
what doing wrong or forgetting?
thanks in advance.
#1 read on sn.exe. generate strong name key file , right-click project in solution explorer , edit properties. choose "signing" tab , add key file. if corporation has key file can delay-sign assembly , pass keeper of private key (you won't have access because extremely locked-down because if public, can sign app's impersonating company.) don't forget open "properties" folder in solution explorer , edit name/version/etc. of assembly.
#2 saying can use dll after you've deleted it? that's hard believe.
#3 installer packages such installshield have provisions registering .net assemblies needed. alternatively can use regasm /regfile generate .reg can merged target registry. recommend either: 1) using commercial tool build installer or 2) being shining god of msi technology, though. difficult write correct installer sdk tools, , wix.
#4 has no workaround far know. guess microsoft decided perverse have managed assembly access managed assembly through managed wrapper assembly on top of com interface wrapper implemented 2nd managed assembly. maybe didn't want become common way around private/global assembly binding rules.
anyway, perhaps edit type library such "fools" managed wrapper generator (tlbimp.exe) thinking native com type library, worth it? commercial applications public api have instructions using app's api com , managed clients, 1 or other being wrapper depending on implementation of application. technique has been working many vendors, without issue, years.
Comments
Post a Comment