6

Scenario: I have a C# application that uses Click-Once to install(puts an icon on the desktop that points to the application) itself on computers on the network. I have recently been integrating NHibernate into the program and everything runs smooth on my box. Its ready for internal testing and I need to put it on our network share (Same share as production, different folder).

Problem: When I place it on the network share and run it I recieve an error saying the application cannot run in partial trust.

Question: I have googled this to no end and every solution seems to talk about a Web Application experiencing this. Is there anyway I can set the application to run in full trust mode on a network share. Setting the folder/exe to full trust? Is this simply allowing "Full Control" in the security tab of my applications properties?

Here is the error I recieve when running the application alt text

Thanks for any input

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
Gage
  • 7,365
  • 9
  • 47
  • 77

2 Answers2

5

You need to set the security policy on the client machine using CasPol.exe or the configuration tool in Administrative Tools.

Alternatively, you can upgrade to .net 4.0, which gets rid of all this.

EDIT: You can also try adding [assembly: AllowPartiallyTrustedCallers]to the referenced assembly.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • @Slaks - +1 More people need to know about caspol.exe. Could you provide a link to more info concerning the changes to .NET 4? – Pieter van Ginkel Nov 11 '10 at 19:06
  • @Pieter: [Security Changes in the .NET Framework 4](http://msdn.microsoft.com/en-us/library/dd233103.aspx) – SLaks Nov 11 '10 at 19:09
  • @Slaks, Is there anyway this could be run remotely/automagically without user interaction. Forcing every user to do this isn't really an option since we don't necessarily know who will be running it. – Gage Nov 11 '10 at 19:28
  • @Gage: Ask your IT infrastructure. – SLaks Nov 11 '10 at 19:52
  • @Slaks, Tried adding that to the assembly with no luck. Recompiled Nhibernate and Castle to allow that and still doesn't work. I would consider trying .Net 4.0 if it worked with VS 2008. Can't justify the upgrade to 2010 – Gage Nov 11 '10 at 20:11
  • @Gage: Installing .Net 3.5 **SP1** on the _client_ machines should also help. (It changes the default policy) – SLaks Nov 11 '10 at 20:18
  • @Slaks, the clients have .Net 3.5 SP1 installed, the only option I'm left with right now is to contact IT like you suggested. I'll post the progress I make. Thanks – Gage Nov 11 '10 at 20:25
3

Putting an Icon on the desktop that points to a network share does not sound like Click-once.

But this 'problem' should be solved from Fx 3.5 SP1 onwards.

H H
  • 263,252
  • 30
  • 330
  • 514
  • It's an application reference that is puts on the desktop. Thought it was an icon, my bad. I am using .Net 3.5 – Gage Nov 11 '10 at 19:23
  • And is it SP1? Would make it a different question. – H H Nov 11 '10 at 19:34
  • I believe so I have 3.5 SP1 installed but it only shows .Net 3.5 in my project setttings. – Gage Nov 11 '10 at 19:39