Hi
I have a vb6 dll that i want to replace with a C# dll (slowly migrating
towards a fully dotnet coded application), but I can't get the event to
work. I've gotten all the methods to work, but there is an event that i
can't catch ( i can't see any event in vb no matter how I declare it)
In vb i use WithEvents and would like to use
"[variable_name]_PositionChanged" for the event
What am i doing wrong? Am i stupid or what? (you don't have to answer
the last Q:-) )
here's the code:
[ClassInterface(ClassInterfaceType.AutoDual)]
public class PositionChangedEventArgs : EventArgs
{
//(string Name, string Street, string City, string PostCode, double
Lat, double Lon);
private string m_Name="";
private string m_Street="";
private string m_City="";
private string m_PostCode="";
private double m_Lat=0;
private double m_Lon=0;
public PositionChangedEventArgs(string Name, string Street, string
City, string PostCode, double Lat, double Lon)
{
m_Name= Name;
m_Street=Street;
m_City=City;
m_PostCode =PostCode;
m_Lat=Lat;
m_Lon=Lon;
}
public string Name
{
get { return m_Name.ToString(); }
}
public string City
{
get { return m_City.ToString(); }
}
public string Street
{
get { return m_Street.ToString(); }
}
public string PostCode
{
get { return m_PostCode.ToString(); }
}
public double Lat
{
get { return m_Lat; }
}
public double Lon
{
get { return m_Lon; }
}
}
//Delegate
public delegate void PositionChangedDelegate(object sender,
PositionChangedEventArgs e);
//Interface
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface _PresentationEvent
{
//A Reference to the PositionChangedDelegate
[DispId(1)]
void PositionChanged(object sender, PositionChangedEventArgs e);
}
//Code from class (only the necessary parts)
public class Presentation : _Presentation
{
public event PositionChangedDelegate PositionChanged;
public bool bln_MapAvailable;
public Presentation()
{}
protected virtual void onPositionChanged(object sender,
PositionChangedEventArgs e)
{
if (PositionChanged != null)
{
PositionChanged(sender,e);
}
}
public void ChangePosition(string Name, string Street, string City,
string PostCode, double Lat, double Lon)
{
PositionChangedEventArgs e = new PositionChangedEventArgs( Name,
Street, City, PostCode, Lat, Lon) ;
onPositionChanged(this,e);
}
}
ogled - 20 Sep 2006 09:35 GMT
Forgot presentation class has these attibs:
[ComSourceInterfaces(typeof(TESGeocode._PresentationEvent))]
[ProgId ("GEOC.Presentation")] // progid
[ClassInterface (ClassInterfaceType.AutoDual)]
> Hi
>
[quoted text clipped - 100 lines]
> }
> }
Thomas Freudenreich - 21 Sep 2006 10:32 GMT
Am 20 Sep 2006 01:35:09 -0700 schrieb ogled:
> From: ogled <erik.lagusson@gmail.com>
> Newsgroups: microsoft.public.dotnet.framework.interop
[quoted text clipped - 127 lines]
>> }
>> }
I have the same problem. The interesting thing is that it works with other
OLE Containers like the testcontainer. So that means VB6 do something
different to register as event sink an that did'nt work.
Thomas
ogled - 25 Sep 2006 11:50 GMT
Funny thing is that i can catch an event without parameters, and then
call a method to get attribs of the class, but i can't do a custom
event with parmaters ...so now i have to change every interface and
callback in the system. Nooooo fun!
> Am 20 Sep 2006 01:35:09 -0700 schrieb ogled:
>
[quoted text clipped - 135 lines]
>
> Thomas
Thomas Freudenreich - 26 Sep 2006 14:08 GMT
Am 25 Sep 2006 03:50:02 -0700 schrieb ogled:
> Funny thing is that i can catch an event without parameters, and then
> call a method to get attribs of the class, but i can't do a custom
[quoted text clipped - 140 lines]
>>
>> Thomas
There is one more difference between your and my program. I try it with a
usercontrol. You have a "simple" class. If you have problems with the args
it has something to do with marshalling. You may try just one "int".
I haven't installed VS2005 at work so I can't try now.
Thomas
ogled - 28 Sep 2006 07:08 GMT
> There is one more difference between your and my program. I try it with a
> usercontrol. You have a "simple" class. If you have problems with the args
> it has something to do with marshalling. You may try just one "int".
> I haven't installed VS2005 at work so I can't try now.
We don't do 2005 (yet), and since i need it to work int the 1.1 sp1
dotnet envoironment i don't know if it is easy to work around the
problem...at the moment I'm focusing on other things, but when it's
time for implementation i might give it another go.
/Erik