[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Use a struct within a remotingObject

mail

6/25/2004 9:58:00 AM

Hello,

I want to use a self defined struct within a remoteObject in the
following way to send data from an AddIn in VisualStudio to an AddIn
in MS Word:

....
public class Remote Object : MarshalByRefObject
{
...
public ArrayList GetCodeElements()
{
...
ArrayList retval = new ArrayList();
foreach(...)
{
StructElement strEl = new StructElement();
strEl.Name = "TestName";
retval.Add(strEl);
}
return retval;
}
...
}

[Serializable]
public struct StructElement
{
...
private string name;

public string Name
{
get { return this.name; }
set { this.name = value; }
}
...
}

When I try all this without the struct in the returning ArrayList only
by using a single string, it works, so I think the remote call by
client is ok. Also there are no problems, when I use a ConsoleApp as
Client and not the AddIn in Word. But when I call the relevant
function out of the Word AddIn, I get an "unmanaged exception" with
the message "The XML-key ... StructElement is not assigned by an
assembly" (my own translation from german to english, sorry :-))

Have you any idea, what I have to do to solve this problem?

Kai Huener
9 Answers

Sunny

6/28/2004 2:35:00 PM

0

Do you use tha same assembly referenced both from the server and the
client. Both programs need to reference and use the same assembly in
which your struct is defined.

Sunny


In article <bff5fc22.0406250157.7bae9e8f@posting.google.com>,
mail@kaihuener.de says...
> Hello,
>
> I want to use a self defined struct within a remoteObject in the
> following way to send data from an AddIn in VisualStudio to an AddIn
> in MS Word:
>
> ...
> public class Remote Object : MarshalByRefObject
> {
> ...
> public ArrayList GetCodeElements()
> {
> ...
> ArrayList retval = new ArrayList();
> foreach(...)
> {
> StructElement strEl = new StructElement();
> strEl.Name = "TestName";
> retval.Add(strEl);
> }
> return retval;
> }
> ...
> }
>
> [Serializable]
> public struct StructElement
> {
> ...
> private string name;
>
> public string Name
> {
> get { return this.name; }
> set { this.name = value; }
> }
> ...
> }
>
> When I try all this without the struct in the returning ArrayList only
> by using a single string, it works, so I think the remote call by
> client is ok. Also there are no problems, when I use a ConsoleApp as
> Client and not the AddIn in Word. But when I call the relevant
> function out of the Word AddIn, I get an "unmanaged exception" with
> the message "The XML-key ... StructElement is not assigned by an
> assembly" (my own translation from german to english, sorry :-))
>
> Have you any idea, what I have to do to solve this problem?
>
> Kai Huener
>

Kai Huener

6/29/2004 9:44:00 AM

0

Hi Sunny,

Yes, the assembly references all are correct, whenn I use the code in a
console Application, there are no problems. Now I tried to wrap also the
struct, like you described in the other post, but its realy ennoying to
write extra code for things which normaly have to work. All would be so
easy, if I could use the CodeElement or Solution Objects from .NET, you
realy don''t know any way to serialize these COM-Objects?

Thank you,
Kai Huener


"Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
news:%23cY1K0RXEHA.3596@tk2msftngp13.phx.gbl...
> Do you use tha same assembly referenced both from the server and the
> client. Both programs need to reference and use the same assembly in
> which your struct is defined.
>
> Sunny
>
>
> In article <bff5fc22.0406250157.7bae9e8f@posting.google.com>,
> mail@kaihuener.de says...
> > Hello,
> >
> > I want to use a self defined struct within a remoteObject in the
> > following way to send data from an AddIn in VisualStudio to an AddIn
> > in MS Word:
> >
> > ...
> > public class Remote Object : MarshalByRefObject
> > {
> > ...
> > public ArrayList GetCodeElements()
> > {
> > ...
> > ArrayList retval = new ArrayList();
> > foreach(...)
> > {
> > StructElement strEl = new StructElement();
> > strEl.Name = "TestName";
> > retval.Add(strEl);
> > }
> > return retval;
> > }
> > ...
> > }
> >
> > [Serializable]
> > public struct StructElement
> > {
> > ...
> > private string name;
> >
> > public string Name
> > {
> > get { return this.name; }
> > set { this.name = value; }
> > }
> > ...
> > }
> >
> > When I try all this without the struct in the returning ArrayList only
> > by using a single string, it works, so I think the remote call by
> > client is ok. Also there are no problems, when I use a ConsoleApp as
> > Client and not the AddIn in Word. But when I call the relevant
> > function out of the Word AddIn, I get an "unmanaged exception" with
> > the message "The XML-key ... StructElement is not assigned by an
> > assembly" (my own translation from german to english, sorry :-))
> >
> > Have you any idea, what I have to do to solve this problem?
> >
> > Kai Huener
> >


Richard Bell

6/29/2004 10:07:00 AM

0

Might be related or not, but marshaling of arrays of user defined structs is
not supported by Com interop.

"Kai Huener" <mail@kaihuener.de> wrote in message
news:ut88a2bXEHA.1684@tk2msftngp13.phx.gbl...
> Hi Sunny,
>
> Yes, the assembly references all are correct, whenn I use the code in a
> console Application, there are no problems. Now I tried to wrap also the
> struct, like you described in the other post, but its realy ennoying to
> write extra code for things which normaly have to work. All would be so
> easy, if I could use the CodeElement or Solution Objects from .NET, you
> realy don''t know any way to serialize these COM-Objects?
>
> Thank you,
> Kai Huener
>
>
> "Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
> news:%23cY1K0RXEHA.3596@tk2msftngp13.phx.gbl...
> > Do you use tha same assembly referenced both from the server and the
> > client. Both programs need to reference and use the same assembly in
> > which your struct is defined.
> >
> > Sunny
> >
> >
> > In article <bff5fc22.0406250157.7bae9e8f@posting.google.com>,
> > mail@kaihuener.de says...
> > > Hello,
> > >
> > > I want to use a self defined struct within a remoteObject in the
> > > following way to send data from an AddIn in VisualStudio to an AddIn
> > > in MS Word:
> > >
> > > ...
> > > public class Remote Object : MarshalByRefObject
> > > {
> > > ...
> > > public ArrayList GetCodeElements()
> > > {
> > > ...
> > > ArrayList retval = new ArrayList();
> > > foreach(...)
> > > {
> > > StructElement strEl = new StructElement();
> > > strEl.Name = "TestName";
> > > retval.Add(strEl);
> > > }
> > > return retval;
> > > }
> > > ...
> > > }
> > >
> > > [Serializable]
> > > public struct StructElement
> > > {
> > > ...
> > > private string name;
> > >
> > > public string Name
> > > {
> > > get { return this.name; }
> > > set { this.name = value; }
> > > }
> > > ...
> > > }
> > >
> > > When I try all this without the struct in the returning ArrayList only
> > > by using a single string, it works, so I think the remote call by
> > > client is ok. Also there are no problems, when I use a ConsoleApp as
> > > Client and not the AddIn in Word. But when I call the relevant
> > > function out of the Word AddIn, I get an "unmanaged exception" with
> > > the message "The XML-key ... StructElement is not assigned by an
> > > assembly" (my own translation from german to english, sorry :-))
> > >
> > > Have you any idea, what I have to do to solve this problem?
> > >
> > > Kai Huener
> > >
>
>


Kai Huener

6/29/2004 10:42:00 AM

0

Thank you, this would explain why my AddIn does not do what I want, but I''m
not shure, if this is realy the probelm, because in a console application, I
can use my selfdefined struct out of the marshaled remoteObject. Perhaps I
have to add some serialisation information, but i don''t know details.

Regards,
Kai Huener

"Richard Bell" <richardb@rogge.co.uk> schrieb im Newsbeitrag
news:%23C7xUDcXEHA.1764@TK2MSFTNGP10.phx.gbl...
> Might be related or not, but marshaling of arrays of user defined structs
is
> not supported by Com interop.
>
> "Kai Huener" <mail@kaihuener.de> wrote in message
> news:ut88a2bXEHA.1684@tk2msftngp13.phx.gbl...
> > Hi Sunny,
> >
> > Yes, the assembly references all are correct, whenn I use the code in a
> > console Application, there are no problems. Now I tried to wrap also the
> > struct, like you described in the other post, but its realy ennoying to
> > write extra code for things which normaly have to work. All would be so
> > easy, if I could use the CodeElement or Solution Objects from .NET, you
> > realy don''t know any way to serialize these COM-Objects?
> >
> > Thank you,
> > Kai Huener
> >
> >
> > "Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
> > news:%23cY1K0RXEHA.3596@tk2msftngp13.phx.gbl...
> > > Do you use tha same assembly referenced both from the server and the
> > > client. Both programs need to reference and use the same assembly in
> > > which your struct is defined.
> > >
> > > Sunny
> > >
> > >
> > > In article <bff5fc22.0406250157.7bae9e8f@posting.google.com>,
> > > mail@kaihuener.de says...
> > > > Hello,
> > > >
> > > > I want to use a self defined struct within a remoteObject in the
> > > > following way to send data from an AddIn in VisualStudio to an AddIn
> > > > in MS Word:
> > > >
> > > > ...
> > > > public class Remote Object : MarshalByRefObject
> > > > {
> > > > ...
> > > > public ArrayList GetCodeElements()
> > > > {
> > > > ...
> > > > ArrayList retval = new ArrayList();
> > > > foreach(...)
> > > > {
> > > > StructElement strEl = new StructElement();
> > > > strEl.Name = "TestName";
> > > > retval.Add(strEl);
> > > > }
> > > > return retval;
> > > > }
> > > > ...
> > > > }
> > > >
> > > > [Serializable]
> > > > public struct StructElement
> > > > {
> > > > ...
> > > > private string name;
> > > >
> > > > public string Name
> > > > {
> > > > get { return this.name; }
> > > > set { this.name = value; }
> > > > }
> > > > ...
> > > > }
> > > >
> > > > When I try all this without the struct in the returning ArrayList
only
> > > > by using a single string, it works, so I think the remote call by
> > > > client is ok. Also there are no problems, when I use a ConsoleApp as
> > > > Client and not the AddIn in Word. But when I call the relevant
> > > > function out of the Word AddIn, I get an "unmanaged exception" with
> > > > the message "The XML-key ... StructElement is not assigned by an
> > > > assembly" (my own translation from german to english, sorry :-))
> > > >
> > > > Have you any idea, what I have to do to solve this problem?
> > > >
> > > > Kai Huener
> > > >
> >
> >
>
>


Richard Bell

6/30/2004 4:44:00 PM

0

But your console app is most likely a Net app? If Com marshaling is the
problem, it will occur when crossing over into unmanaged code.

"Kai Huener" <mail@kaihuener.de> wrote in message
news:eFREzWcXEHA.3188@TK2MSFTNGP09.phx.gbl...
> Thank you, this would explain why my AddIn does not do what I want, but
I''m
> not shure, if this is realy the probelm, because in a console application,
I
> can use my selfdefined struct out of the marshaled remoteObject. Perhaps I
> have to add some serialisation information, but i don''t know details.
>
> Regards,
> Kai Huener
>
> "Richard Bell" <richardb@rogge.co.uk> schrieb im Newsbeitrag
> news:%23C7xUDcXEHA.1764@TK2MSFTNGP10.phx.gbl...
> > Might be related or not, but marshaling of arrays of user defined
structs
> is
> > not supported by Com interop.
> >
> > "Kai Huener" <mail@kaihuener.de> wrote in message
> > news:ut88a2bXEHA.1684@tk2msftngp13.phx.gbl...
> > > Hi Sunny,
> > >
> > > Yes, the assembly references all are correct, whenn I use the code in
a
> > > console Application, there are no problems. Now I tried to wrap also
the
> > > struct, like you described in the other post, but its realy ennoying
to
> > > write extra code for things which normaly have to work. All would be
so
> > > easy, if I could use the CodeElement or Solution Objects from .NET,
you
> > > realy don''t know any way to serialize these COM-Objects?
> > >
> > > Thank you,
> > > Kai Huener
> > >
> > >
> > > "Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
> > > news:%23cY1K0RXEHA.3596@tk2msftngp13.phx.gbl...
> > > > Do you use tha same assembly referenced both from the server and the
> > > > client. Both programs need to reference and use the same assembly in
> > > > which your struct is defined.
> > > >
> > > > Sunny
> > > >
> > > >
> > > > In article <bff5fc22.0406250157.7bae9e8f@posting.google.com>,
> > > > mail@kaihuener.de says...
> > > > > Hello,
> > > > >
> > > > > I want to use a self defined struct within a remoteObject in the
> > > > > following way to send data from an AddIn in VisualStudio to an
AddIn
> > > > > in MS Word:
> > > > >
> > > > > ...
> > > > > public class Remote Object : MarshalByRefObject
> > > > > {
> > > > > ...
> > > > > public ArrayList GetCodeElements()
> > > > > {
> > > > > ...
> > > > > ArrayList retval = new ArrayList();
> > > > > foreach(...)
> > > > > {
> > > > > StructElement strEl = new StructElement();
> > > > > strEl.Name = "TestName";
> > > > > retval.Add(strEl);
> > > > > }
> > > > > return retval;
> > > > > }
> > > > > ...
> > > > > }
> > > > >
> > > > > [Serializable]
> > > > > public struct StructElement
> > > > > {
> > > > > ...
> > > > > private string name;
> > > > >
> > > > > public string Name
> > > > > {
> > > > > get { return this.name; }
> > > > > set { this.name = value; }
> > > > > }
> > > > > ...
> > > > > }
> > > > >
> > > > > When I try all this without the struct in the returning ArrayList
> only
> > > > > by using a single string, it works, so I think the remote call by
> > > > > client is ok. Also there are no problems, when I use a ConsoleApp
as
> > > > > Client and not the AddIn in Word. But when I call the relevant
> > > > > function out of the Word AddIn, I get an "unmanaged exception"
with
> > > > > the message "The XML-key ... StructElement is not assigned by an
> > > > > assembly" (my own translation from german to english, sorry :-))
> > > > >
> > > > > Have you any idea, what I have to do to solve this problem?
> > > > >
> > > > > Kai Huener
> > > > >
> > >
> > >
> >
> >
>
>


Sunny

6/30/2004 6:34:00 PM

0

Hi Kai,

when the addin is loaded, it''s process folder is not the folder from
which it is loaded, but the folder of the running process. So most
probably the framework tries to find the assembly with the struct in
some other folder and fails.

I had this problems before, so 2 possible solutions:
1. Put it in the GAC
2. in your Connect method capture the AppDomain.AssemblyResolve event
and try in the handler to load the assembly from the path you want.


Hope that helps
Sunny


In article <eFREzWcXEHA.3188@TK2MSFTNGP09.phx.gbl>, mail@kaihuener.de
says...
> Thank you, this would explain why my AddIn does not do what I want, but I''m
> not shure, if this is realy the probelm, because in a console application, I
> can use my selfdefined struct out of the marshaled remoteObject. Perhaps I
> have to add some serialisation information, but i don''t know details.
>
> Regards,
> Kai Huener
>
> "Richard Bell" <richardb@rogge.co.uk> schrieb im Newsbeitrag
> news:%23C7xUDcXEHA.1764@TK2MSFTNGP10.phx.gbl...
> > Might be related or not, but marshaling of arrays of user defined structs
> is
> > not supported by Com interop.
> >
> > "Kai Huener" <mail@kaihuener.de> wrote in message
> > news:ut88a2bXEHA.1684@tk2msftngp13.phx.gbl...
> > > Hi Sunny,
> > >
> > > Yes, the assembly references all are correct, whenn I use the code in a
> > > console Application, there are no problems. Now I tried to wrap also the
> > > struct, like you described in the other post, but its realy ennoying to
> > > write extra code for things which normaly have to work. All would be so
> > > easy, if I could use the CodeElement or Solution Objects from .NET, you
> > > realy don''t know any way to serialize these COM-Objects?
> > >
> > > Thank you,
> > > Kai Huener
> > >
> > >
> > > "Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
> > > news:%23cY1K0RXEHA.3596@tk2msftngp13.phx.gbl...
> > > > Do you use tha same assembly referenced both from the server and the
> > > > client. Both programs need to reference and use the same assembly in
> > > > which your struct is defined.
> > > >
> > > > Sunny
> > > >
> > > >
> > > > In article <bff5fc22.0406250157.7bae9e8f@posting.google.com>,
> > > > mail@kaihuener.de says...
> > > > > Hello,
> > > > >
> > > > > I want to use a self defined struct within a remoteObject in the
> > > > > following way to send data from an AddIn in VisualStudio to an AddIn
> > > > > in MS Word:
> > > > >
> > > > > ...
> > > > > public class Remote Object : MarshalByRefObject
> > > > > {
> > > > > ...
> > > > > public ArrayList GetCodeElements()
> > > > > {
> > > > > ...
> > > > > ArrayList retval = new ArrayList();
> > > > > foreach(...)
> > > > > {
> > > > > StructElement strEl = new StructElement();
> > > > > strEl.Name = "TestName";
> > > > > retval.Add(strEl);
> > > > > }
> > > > > return retval;
> > > > > }
> > > > > ...
> > > > > }
> > > > >
> > > > > [Serializable]
> > > > > public struct StructElement
> > > > > {
> > > > > ...
> > > > > private string name;
> > > > >
> > > > > public string Name
> > > > > {
> > > > > get { return this.name; }
> > > > > set { this.name = value; }
> > > > > }
> > > > > ...
> > > > > }
> > > > >
> > > > > When I try all this without the struct in the returning ArrayList
> only
> > > > > by using a single string, it works, so I think the remote call by
> > > > > client is ok. Also there are no problems, when I use a ConsoleApp as
> > > > > Client and not the AddIn in Word. But when I call the relevant
> > > > > function out of the Word AddIn, I get an "unmanaged exception" with
> > > > > the message "The XML-key ... StructElement is not assigned by an
> > > > > assembly" (my own translation from german to english, sorry :-))
> > > > >
> > > > > Have you any idea, what I have to do to solve this problem?
> > > > >
> > > > > Kai Huener
> > > > >
> > >
> > >
> >
> >
>
>
>

Kai Huener

7/2/2004 8:12:00 AM

0

Hi Sunny,

Thank you again and again for helping me, but this time I could not score
with your tip. First I thought, to put the assembly to the GAC would solve
the problem, but the Exception was the same. I did the following:

1. I createt a key pair to get a strong name for the assembly
2. I added the attribute "[assembly:AssemblyKeyFileAttribute(keyFileName)]"
to the struct code
3. I added the assembly to the GAC by using the .NET Framework Configuration
Tool
4. (Here I was not realy sure!) I added a refference to the lokal
(ProjectFolder) stored assembly

I''m not sure, how to reference an assembly placed in the GAC, but I could
not find any other assembly as this one in my ProjectFolder.

Ok, this didn''t work, then I wanted to try your tip No. 2, but I could not
find any AppDomain-Object out of my AddIn-File. There I have only a
Microsoft.Office.Interop.Word.Application-Object, but there is no AppDomain
in view. Can you tell me, how to get it out of the OnConnection-Method of my
AddIn?

I hope not to bore you :-)
Thank you and Regards,
Kai


"Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
news:%23e8EZDtXEHA.2868@TK2MSFTNGP09.phx.gbl...
> Hi Kai,
>
> when the addin is loaded, it''s process folder is not the folder from
> which it is loaded, but the folder of the running process. So most
> probably the framework tries to find the assembly with the struct in
> some other folder and fails.
>
> I had this problems before, so 2 possible solutions:
> 1. Put it in the GAC
> 2. in your Connect method capture the AppDomain.AssemblyResolve event
> and try in the handler to load the assembly from the path you want.
>
>
> Hope that helps
> Sunny
>
>
> In article <eFREzWcXEHA.3188@TK2MSFTNGP09.phx.gbl>, mail@kaihuener.de
> says...
> > Thank you, this would explain why my AddIn does not do what I want, but
I''m
> > not shure, if this is realy the probelm, because in a console
application, I
> > can use my selfdefined struct out of the marshaled remoteObject. Perhaps
I
> > have to add some serialisation information, but i don''t know details.
> >
> > Regards,
> > Kai Huener
> >
> > "Richard Bell" <richardb@rogge.co.uk> schrieb im Newsbeitrag
> > news:%23C7xUDcXEHA.1764@TK2MSFTNGP10.phx.gbl...
> > > Might be related or not, but marshaling of arrays of user defined
structs
> > is
> > > not supported by Com interop.
> > >
> > > "Kai Huener" <mail@kaihuener.de> wrote in message
> > > news:ut88a2bXEHA.1684@tk2msftngp13.phx.gbl...
> > > > Hi Sunny,
> > > >
> > > > Yes, the assembly references all are correct, whenn I use the code
in a
> > > > console Application, there are no problems. Now I tried to wrap also
the
> > > > struct, like you described in the other post, but its realy ennoying
to
> > > > write extra code for things which normaly have to work. All would be
so
> > > > easy, if I could use the CodeElement or Solution Objects from .NET,
you
> > > > realy don''t know any way to serialize these COM-Objects?
> > > >
> > > > Thank you,
> > > > Kai Huener
> > > >
> > > >
> > > > "Sunny" <sunnyask@icebergwireless.com> schrieb im Newsbeitrag
> > > > news:%23cY1K0RXEHA.3596@tk2msftngp13.phx.gbl...
> > > > > Do you use tha same assembly referenced both from the server and
the
> > > > > client. Both programs need to reference and use the same assembly
in
> > > > > which your struct is defined.
> > > > >
> > > > > Sunny
> > > > >
> > > > >
> > > > > In article <bff5fc22.0406250157.7bae9e8f@posting.google.com>,
> > > > > mail@kaihuener.de says...
> > > > > > Hello,
> > > > > >
> > > > > > I want to use a self defined struct within a remoteObject in the
> > > > > > following way to send data from an AddIn in VisualStudio to an
AddIn
> > > > > > in MS Word:
> > > > > >
> > > > > > ...
> > > > > > public class Remote Object : MarshalByRefObject
> > > > > > {
> > > > > > ...
> > > > > > public ArrayList GetCodeElements()
> > > > > > {
> > > > > > ...
> > > > > > ArrayList retval = new ArrayList();
> > > > > > foreach(...)
> > > > > > {
> > > > > > StructElement strEl = new StructElement();
> > > > > > strEl.Name = "TestName";
> > > > > > retval.Add(strEl);
> > > > > > }
> > > > > > return retval;
> > > > > > }
> > > > > > ...
> > > > > > }
> > > > > >
> > > > > > [Serializable]
> > > > > > public struct StructElement
> > > > > > {
> > > > > > ...
> > > > > > private string name;
> > > > > >
> > > > > > public string Name
> > > > > > {
> > > > > > get { return this.name; }
> > > > > > set { this.name = value; }
> > > > > > }
> > > > > > ...
> > > > > > }
> > > > > >
> > > > > > When I try all this without the struct in the returning
ArrayList
> > only
> > > > > > by using a single string, it works, so I think the remote call
by
> > > > > > client is ok. Also there are no problems, when I use a
ConsoleApp as
> > > > > > Client and not the AddIn in Word. But when I call the relevant
> > > > > > function out of the Word AddIn, I get an "unmanaged exception"
with
> > > > > > the message "The XML-key ... StructElement is not assigned by an
> > > > > > assembly" (my own translation from german to english, sorry :-))
> > > > > >
> > > > > > Have you any idea, what I have to do to solve this problem?
> > > > > >
> > > > > > Kai Huener
> > > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >


Sunny

7/2/2004 2:43:00 PM

0

Hi Kai,

In article <Of14swAYEHA.3420@TK2MSFTNGP12.phx.gbl>, mail@kaihuener.de
says...
> Hi Sunny,
>
> Ok, this didn''t work, then I wanted to try your tip No. 2, but I could not
> find any AppDomain-Object out of my AddIn-File. There I have only a
> Microsoft.Office.Interop.Word.Application-Object, but there is no AppDomain
> in view. Can you tell me, how to get it out of the OnConnection-Method of my
> AddIn?
>


This I have in my Connect() method:

public Connect()
{
app_domain = System.AppDomain.CurrentDomain;
app_domain.AssemblyResolve += new ResolveEventHandler
(app_domain_AssemblyResolve);
app_domain.UnhandledException += new UnhandledExceptionEventHandler
(app_domain_UnhandledException);
}


Note that I also handle UnhandledExceptions. I found out that if
something goes wrong and the addin throws an exception which is not
caught, the host app disables the addin without any notice and it is
very hard to debug and to see what is wrong.

If you are using some windows forms with your addin as well, maybe you
should trap ThreadException as well.
Here is an article about unhandled exceptions. They say there that
generally this is bad idea to handle everything, but in the case with
addins I found that it is more useful.

http://msdn.microsoft.com/msdnmag/issues/04/06/NET/de...



Hope that helps
Sunny

Kai Huener

7/3/2004 3:30:00 PM

0

Hi Sunny,

Thank you for your code, it solved exactly the exception. But now I get the
Problem, Richard Bell described in the Posting from 30.6.04 18:44 because it
is not possible to return the selfdefined Struct by a Method of my
RemoteObject, and this is, why I wanted to use all this. Now - after 3 days
work for nothing I''m really fed of all this shit, and I will wrap each
atomic operation, so that I only return strings and ints out of my
RemoteObject. I have no idea, why this is not suported, but that''s life.

Nevertheless thank you for all your help,
Kai Huener

"Sunny" <sunny@newsgroups.nospam> schrieb im Newsbeitrag
news:uJFhiLEYEHA.3520@TK2MSFTNGP10.phx.gbl...
> Hi Kai,
>
> In article <Of14swAYEHA.3420@TK2MSFTNGP12.phx.gbl>, mail@kaihuener.de
> says...
> > Hi Sunny,
> >
> > Ok, this didn''t work, then I wanted to try your tip No. 2, but I could
not
> > find any AppDomain-Object out of my AddIn-File. There I have only a
> > Microsoft.Office.Interop.Word.Application-Object, but there is no
AppDomain
> > in view. Can you tell me, how to get it out of the OnConnection-Method
of my
> > AddIn?
> >
>
>
> This I have in my Connect() method:
>
> public Connect()
> {
> app_domain = System.AppDomain.CurrentDomain;
> app_domain.AssemblyResolve += new ResolveEventHandler
> (app_domain_AssemblyResolve);
> app_domain.UnhandledException += new UnhandledExceptionEventHandler
> (app_domain_UnhandledException);
> }
>
>
> Note that I also handle UnhandledExceptions. I found out that if
> something goes wrong and the addin throws an exception which is not
> caught, the host app disables the addin without any notice and it is
> very hard to debug and to see what is wrong.
>
> If you are using some windows forms with your addin as well, maybe you
> should trap ThreadException as well.
> Here is an article about unhandled exceptions. They say there that
> generally this is bad idea to handle everything, but in the case with
> addins I found that it is more useful.
>
> http://msdn.microsoft.com/msdnmag/issues/04/06/NET/de...
>
>
>
> Hope that helps
> Sunny