webForumDet fria alternativet

Hur ändrar jag trust level?

.NET

3 svar · 278 visningar · startad av trexter

Medlem sedan mars 20021 889 inlägg
Frågan#1

System.Security.SecurityException: Requested registry access is not allowed.
Jag får felmeddelandet ovan och vill gå in i machine.config och ändra "trust level". Frågan är hur. :)

Medlem sedan apr. 20012 266 inlägg
#2

Hittade följande i machine.config

<!-- 
        Using a location directive with a missing path attribute
        scopes the configuration to the entire machine.  If used in 
        conjunction with allowOverride="false", it can be used to 
        prevent configuration from being altered on the machine

        Administrators that want to restrict permissions granted to 
        web applications should change the default Trust level and ensure
        that overrides are not allowed
    -->
	<location allowOverride="true">
		<system.web>
			<securityPolicy>
				<trustLevel name="Full" policyFile="internal"/>
				<trustLevel name="High" policyFile="web_hightrust.config"/>
				<trustLevel name="Medium" policyFile="web_mediumtrust.config"/>
				<trustLevel name="Low" policyFile="web_lowtrust.config"/>
				<trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>
			</securityPolicy>
			<!--  level="[Full|High|Medium|Low|Minimal]" -->
			<trust level="Full" originUrl=""/>
		</system.web>
	</location>

Det bör då gå att lägga in <trust level=""> i din web.config.

Medlem sedan mars 20021 889 inlägg
#3

Hur ska web.config-filen se ut? Jag har provat på lite olika sätt, bland annat så här:

<configuration>
<appSettings>
<trust level="full" />
</appSettings>

\<system.web\>
\</system.web\>

</configuration>

men .Net kommer ändå med samma felmeddelande.

Medlem sedan apr. 20012 266 inlägg
#4

Som du ser i exemplet ovan så ligger <trust> inom <system.web> och inte <appSettings>. Testa dvs att lägga trust inom system.web

260 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
125 ms — deklarationer (db)
0 ms — hämta statistik (cache)
131 ms — hämta tråd, inlägg och bilagor (db)
125 ms — ändringar (db)