Discussion:
Batch job not getting suffient permissions to access CLR object
(too old to reply)
Eduardo
2010-08-03 17:15:03 UTC
Permalink
Hi,

A Batch job needs to send an email to a bunch of people, but it is not
letting me do it as I get an error saying that IteropPermission does not have
all the rights to create the CLR object.

I created the:
perm = new InteropPermission( InteropKind::CLRInterop);
perm.assert();

After I tried this code I got another error message that I'm missing the
ComInterop permissions, and I don't how to approach the situation as if I
instantiate 1, the other is missing. In addition, when I try to instatiate
both, I get an error message saying that I cannot make multiples calls to
this class ...

This code is referring the System.Net dll.

Any help will be greatly appreciated.

Thanks!

Eduardp
Klaas Deforche
2010-08-04 08:03:03 UTC
Permalink
Hi Eduardo,

To assert multiple permissions, use the
CodeAccessPermission::assertMultiple() method. More info here:
http://msdn.microsoft.com/en-us/library/aa609747.aspx

Basically, just create a set, and you *Permission object to it, and use the
assertMultiple(yourSet) function to assert them.

That way, you only call the assert method once.

Hope this helps,
Best regards,
Klaas Deforche.
----------------
http://www.artofcreation.be
Post by Eduardo
Hi,
A Batch job needs to send an email to a bunch of people, but it is not
letting me do it as I get an error saying that IteropPermission does not have
all the rights to create the CLR object.
perm = new InteropPermission( InteropKind::CLRInterop);
perm.assert();
After I tried this code I got another error message that I'm missing the
ComInterop permissions, and I don't how to approach the situation as if I
instantiate 1, the other is missing. In addition, when I try to instatiate
both, I get an error message saying that I cannot make multiples calls to
this class ...
This code is referring the System.Net dll.
Any help will be greatly appreciated.
Thanks!
Eduardp
Eduardo
2010-08-04 16:31:03 UTC
Permalink
Klaas,

Thanks a lot for the info. I appreciated!

Eduardo
Post by Klaas Deforche
Hi Eduardo,
To assert multiple permissions, use the
http://msdn.microsoft.com/en-us/library/aa609747.aspx
Basically, just create a set, and you *Permission object to it, and use the
assertMultiple(yourSet) function to assert them.
That way, you only call the assert method once.
Hope this helps,
Best regards,
Klaas Deforche.
----------------
http://www.artofcreation.be
Post by Eduardo
Hi,
A Batch job needs to send an email to a bunch of people, but it is not
letting me do it as I get an error saying that IteropPermission does not have
all the rights to create the CLR object.
perm = new InteropPermission( InteropKind::CLRInterop);
perm.assert();
After I tried this code I got another error message that I'm missing the
ComInterop permissions, and I don't how to approach the situation as if I
instantiate 1, the other is missing. In addition, when I try to instatiate
both, I get an error message saying that I cannot make multiples calls to
this class ...
This code is referring the System.Net dll.
Any help will be greatly appreciated.
Thanks!
Eduardp
Eduardo
2010-08-04 19:27:03 UTC
Permalink
Klaas,

I'm just placing my code here to help someone else in the future with my
same question. What you suggested worked great, and again I really thank you
for your help.

//Variables
InteropPermission perm;
InteropPermission perm2;
InteropPermission perm3;
Set permissionSet;

perm = new InteropPermission(InteropKind::ClrInterop);
perm2 = new InteropPermission(InteropKind::DllInterop);
perm3 = new InteropPermission(InteropKind::ComInterop);
permissionSet = new Set(Types::Class);
permissionSet.add(perm);
permissionSet.add(perm2);
permissionSet.add(perm3);
CodeAccessPermission::assertMultiple(permissionSet);
Post by Klaas Deforche
Hi Eduardo,
To assert multiple permissions, use the
http://msdn.microsoft.com/en-us/library/aa609747.aspx
Basically, just create a set, and you *Permission object to it, and use the
assertMultiple(yourSet) function to assert them.
That way, you only call the assert method once.
Hope this helps,
Best regards,
Klaas Deforche.
----------------
http://www.artofcreation.be
Post by Eduardo
Hi,
A Batch job needs to send an email to a bunch of people, but it is not
letting me do it as I get an error saying that IteropPermission does not have
all the rights to create the CLR object.
perm = new InteropPermission( InteropKind::CLRInterop);
perm.assert();
After I tried this code I got another error message that I'm missing the
ComInterop permissions, and I don't how to approach the situation as if I
instantiate 1, the other is missing. In addition, when I try to instatiate
both, I get an error message saying that I cannot make multiples calls to
this class ...
This code is referring the System.Net dll.
Any help will be greatly appreciated.
Thanks!
Eduardp
Loading...