all groups > dotnet remoting > september 2006 >
You're in the

dotnet remoting

group:

Using remoting features inside a .NET applet loaded in a tag object


Using remoting features inside a .NET applet loaded in a tag object Lambuz
9/21/2006 6:41:16 AM
dotnet remoting:
First of all, is it possible usign .NET remoting feature inside a .NET
applet loaded into a tag object inside an HTML page ?

<OBJECT id="myID" height="150" width="300"
classid="http:applet.dll#test.applet"> </OBJECT>

If not please can anyone explain why ?

I think yes and so I'd written a small example immediately I've met a
problem.

I'm using .NET Framework v. 1.1.4322 and it's the only version
installed both client side and server side.

My test applet is correctly loaded into IE client but when I try to
setting programmatically the remoting I aways obtain a
SecurityException even if the assembly is strong name signed and client
side fully trusted.

The exception is the following:
System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.SecurityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed.
at
System.Security.CodeAccessSecurityEngine.CheckTokenBasedSetHelper(Boolean
ignoreGrants, TokenBasedSet grants, TokenBasedSet denied, TokenBasedSet
demands)
at
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet
grants, PermissionSet denied, PermissionSet demands)
at
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(IChannel
chnl) at test.applet.Check()

Could anyone help me please ?

Best regards
Re: Using remoting features inside a .NET applet loaded in a tag object Dmytro Lapshyn [MVP]
9/22/2006 12:00:00 AM
Hi,

..NET controls, when loaded inside IE, are given pretty restricted security
permissions. In particular, they are not allowed to access the network. You
can change this permission set by using the .NET Framework configuration
tools, but this will have to be done on every machine where your code is
going to be used.

Consider using an AJAX-like approach when JavaScript code on the page uses
the XMLHttpRequest object to talk to the server and then feeds the received
data to the .NET object hosted within the OBJECT tag.

--
Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

[quoted text, click to view]
Re: Using remoting features inside a .NET applet loaded in a tag object Lambuz
9/22/2006 12:37:23 AM
[quoted text, click to view]

While I was waiting an answer from somebody I've solved my problem, but
now I've got another one.

The code I'm using is the following:

PermissionSet ps = new PermissionSet(PermissionState.None);
ps.AddPermission(new SecurityPermission(PermissionState.Unrestricted));

ps.AddPermission(new SocketPermission(PermissionState.Unrestricted));
ps.Assert();

TcpClientChannel _channel = new TcpClientChannel();
ChannelServices.RegisterChannel(_channel);
RemotingConfiguration.RegisterActivatedClientType(typeof(DataProvider),"tcp://localhost:8081");

//DataProvider dp = (DataProvider)
(Activator.CreateInstance(typeof(DataProvider)));
DataProvider dp = new DataProvider();


As you can see even if my assembly is strong name signed and fully
trusted by strong nome reference I must create to permission and it's
very strange for me...can you explain to me ?

My real problem is that if I create my remote object by Activatar
object I always obtain the following exception:

System.Security.SecurityException: Request failed.
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at IBM.Cipros.Refinery.CPRSWebClient.Check()

The granted set of the failing assembly was:
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission
class="System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Read="USERNAME"/>
<IPermission
class="System.Security.Permissions.FileDialogPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission
class="System.Security.Permissions.IsolatedStorageFilePermission,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Allowed="AssemblyIsolationByUser"
UserQuota="9223372036854775807"
Expiry="9223372036854775807"
Permanent="True"/>
<IPermission
class="System.Security.Permissions.ReflectionPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="ReflectionEmit"/>
<IPermission class="System.Security.Permissions.SecurityPermission,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Assertion, Execution, BindingRedirects"/>
<IPermission class="System.Security.Permissions.UIPermission,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Net.DnsPermission, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Drawing.Printing.PrintingPermission,
System.Drawing, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
version="1"
Level="DefaultPrinting"/>
<IPermission class="System.Diagnostics.EventLogPermission, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1">
<Machine name="."
access="Instrument"/>
</IPermission>
<IPermission class="System.Net.WebPermission, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1">
<ConnectAccess>
<URI uri="(https|http)://localhost/.*"/>
</ConnectAccess>
</IPermission>
<IPermission
class="System.Security.Permissions.SiteIdentityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Site="localhost"/>
<IPermission
class="System.Security.Permissions.UrlIdentityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Url="http://localhost/"/>
<IPermission
class="System.Security.Permissions.ZoneIdentityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Zone="Intranet"/>
</PermissionSet>

If I use directly the contructor of my remote object it takes a couple
of minute to create it, it is very strange because if I use the
prevoius code inside a console application the remote creation is very
quickly, quite immediat. Do you know the reason ?


[quoted text, click to view]

it is already the first alternative if my initial solution is
impossible to realize.
AddThis Social Bookmark Button