vb.net - referencing a dll in a windows service -


i wrote opc client using interop.opcautomation.dll. wrote windows form in vb 2010 express. working well. wanted make windows service though. problem having not connect opc server when run service. following exception "object reference not set instance of object.- opc connect error" exception @ end of code trying connect. below code. input, appreciated.

imports system.serviceprocess imports system.threading imports system.text imports system.windows.forms imports system imports system.io imports system.io.file imports system.net imports opcautomation   public class service1     inherits system.serviceprocess.servicebase      dim withevents opcserver opcautomation.opcserver     dim withevents connectedgroup opcautomation.opcgroup      dim batch string     dim group string     dim press string     dim line string     dim swidth string     dim sheight string     dim sbifold string     dim score string     dim startup integer     dim ihandle integer     dim serror string      dim itemids(60) string     dim serverhandles array     dim clienthandles(60) integer     dim servererrors array      dim snapserverurl string = "snapserver"      private trd thread     private stopping boolean = false     private stoppedevent new manualresetevent(false)      protected overrides sub onstart(byval args() string)          eventlog.writeentry("presscontrolservice in onstart.")          trd = new thread(addressof servicemain)         trd.isbackground = true         trd.start()      end sub      protected overrides sub onstop()          eventlog.writeentry("presscontrolservice in onstop.")         me.stopping = true         me.stoppedevent.waitone()      end sub      private sub servicemain()          dim stropcservername string         dim stropcservernode string         dim stropcgroupname string         dim integer          startup = 0         stropcservername = "kepware.kepserverex.v5"         stropcservernode = ""         stropcgroupname = "mygroup"         try             dim opcserver new opcautomation.opcserver         catch ex exception             eventlog.writeentry(ex.message & " - new opc server")         end try          try             opcserver.connect(stropcservername, stropcservernode)         catch ex exception             eventlog.writeentry(ex.message & "- opc connect error")         end try     end sub end class 


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -