Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

vb.net - Raising events in a class library exposed to COM -


i'm trying write wrapper service, used existing vb6 project. i've got of basic framework working, except 1 important aspect: can reference wrapper in vb6 project , subs/function calls etc. work expected, events not. events visible in vb6 app, never fire.

vb.net code:

public event action_response(byval status string) public function testevent()     raiseevent action_response("test done")     return "done" end function 

vb6 code:

dim withevents my_wrapper wrapper_class private sub cmdtest_click()     set my_wrapper = new wrapper_class     debug.print my_wrapper.testevent()  end sub  private sub my_wrapper_action_response(byval status string)     debug.print status     set my_wrapper = nothing end sub 

so, cmdtest button code prints 'done' expected, action_response event doesn't fire. there else need event fire?

its write in comment, i'll make answer....

first, identify .net class want expose com. i'll pick class called core.

create interface describes events core object source (ie generate).

<comvisible(true)> _ <guid("some guid here...use guidgen, i'll call guid1")> _ <interfacetype(cominterfacetype.interfaceisidispatch)> _ public interface icoreevents     <system.runtime.interopservices.dispid(1)> _     sub fileloaded(byval message string) end interface 

next, create interface com exposed properties , methods of class.

<comvisible(true)> _ <guid("another guid, i'll call guid2")> _ <interfacetype(cominterfacetype.interfaceisdual)> _ public interface icore     readonly property property1() boolean     readonly property anotherproperty() isettings     readonly property name() string     readonly property phone() string end interface 

now, create actual .net class

<comvisible(true)> _ <classinterface(classinterfacetype.none)> _ <comdefaultinterface(gettype(icore))> _ <comsourceinterfaces(gettype(icoreevents))> _ <guid("a third guid, i'll call guid3")> _ public class core     implements icore      <system.runtime.interopservices.comvisible(false)> _     public delegate sub onfileloaded(byval message string)     public event fileloaded onfileloaded end class 

now, when need raise fileloaded event, raiseevent fileloaded(message) within class. .net forward event out com because you've hooked comsourceinterfaces attribute.

the attribute shorthand of of this, unfortunately doesn't give quite control need things (for instance retain version compatibility on com interfaces).


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -