Book a Demo

Author Topic: Addin allowing partially trusted callers  (Read 3179 times)

fferm

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Addin allowing partially trusted callers
« on: November 11, 2010, 09:05:54 pm »
I'm trying to create an add-in to Enterprise Architect.  I have created a .Net C# assembly that contains a class implementing the EA_OnPostNewElement method.

If my method only does something simple, like exposing a messagebox with a simple text message, everything works fine.  But when I try to do something more interesting which involves actually using the EnterpriseArchitect API, I get an error message.

The error message says the following:
An error occurred while attempting to communicate with an Addin:
Test(Test.Test)
"EA_OnPostNewElement: That assembly does not allow partially trusted callers."
Please contact the add-in provider for assistance.


The error message points to problems with the security mechanisms of COM-.Net interop.  To get around these problems, I have done the following things:
- Registered the assembly with the regasm tool
- Provided a strong name for the assembly with a .snk file, declaring it in the AssemblyInfo.cs file like so:
[assembly: AssemblyKeyFile("sn.snk")]
- Declared the assembly as allowing partially trusted callers through the following entry in the AssemblyInfo.cs file:
[assembly: AllowPartiallyTrustedCallers]


What else should I do to make this work?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Addin allowing partially trusted callers
« Reply #1 on: November 12, 2010, 05:19:37 pm »
I'm thinking there must be something wrong with the code, because i've never had any issues like that.

Registering with regasm is a must, (for EA to be able to find your dll), but that should be all you need to do. (if you use Visual Studio it can register the dll for you)

If you post your addin code I'm happy to have a look to see if there is something obvious...

Geert

fferm

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Addin allowing partially trusted callers
« Reply #2 on: November 16, 2010, 12:12:22 am »
After some e-mail conversation with Geert, where I sent him my code (wasn't able to do that here online) we came to the conclusion that the problem was due to the fact that my dll was stored on the network and not on my local machine.  I had it set up so that I do my development under "My Documents" which is mapped to a network location...

Thanx for your help Geert :-)