Cannot call C# library exposed through COM in Excel VBA -


i have tried create basic c# library , expose through com interface can access vba, @ runtime throws error "class not support automation or not support expected interface"

i have read online tutorials , done specified confused why is. basic class is

using system; using system.collections.generic; using system.linq; using system.text; using system.runtime.interopservices;  namespace pdccomtest {      [comvisible(true)]     public interface ipdccomtest     {         string submitrequest(string requestxml);     }      [comvisible(true)]     [classinterface(classinterfacetype.none)]     [comsourceinterfaces(typeof(ipdccomtest))]     [progid("pdccomtest.pdccomtest")]     public class pdccomtest : ipdccomtest     {         public string submitrequest(string requestxml)         {             return "hello world";         }     } } 

and in project settings have gone application -> assembly information -> make assembly com visible (set on) , build -> register com interop (set on)

i compile , build solution, load excel , set basic button macro sheet. in this, go references , under list of com objects, new c# com assembly appears , check it. able discover types intellisense , submitrequest method available intellisense picking fine. vba code follows

private sub commandbutton1_click()     dim oobj new pdccomtest.pdccomtest     dim text string     test = oobj.submitrequest("test") end sub 

when run sheet , click button, throws error on last line of sub above, ie submitrequest() line

"error 430 : class not support automation or not support expected interface"

can please suggest have overlooked , why happening?

thanks, james

this works on machine code fine. if hazard guess, looks .net loading issue, i.e. excel has loaded other .net add-ins , loaded clr v1 or such.

take @ this answer - hope helps.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -