.NET

Reply
Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 1 of 3 (1,842 Views)
Accepted Solution

Windows 7 .NET Security Permission

1842 Views, 2 Replies
03-23-2012 08:28 AM

I need to change my .NET security settings. 

Were is the .NET security modify control panel screen or the CasPol.exe in Windows 7 ? 

I know this isn't Autocad specific, but I'd thought someone has come across this in Windows 7 before.

 

 

 

Cannot load assembly. Error details: System.IO.FileLoadException: Could not
load file or assembly 'ClassAutocad2011, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. Access is denied.
File name: 'ClassAutocad2011, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' ---> System.UnauthorizedAccessException: Access is denied.
(Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark,
Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Autodesk.AutoCAD.Runtime.ExtensionLoader.Load(String fileName)
at loadmgd()

Okay solved it myself. 

 

Use %SYSTEMROOT%

 

Caspol.exe still exists on Windows 7 just didn't know the right folder to be looking. Duh!

 

objShell.run("%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -pp off -m -ag 1.2 -url file://K:/SFARSTDS/Acad_Support/VB.NET/* FullTrust")

Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 2 of 3 (1,839 Views)

Re: Windows 7 .NET Security Permission

03-23-2012 08:51 AM in reply to: VB_Autocad_guy

Okay solved it myself. 

 

Use %SYSTEMROOT%

 

Caspol.exe still exists on Windows 7 just didn't know the right folder to be looking. Duh!

 

objShell.run("%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -pp off -m -ag 1.2 -url file://K:/SFARSTDS/Acad_Support/VB.NET/* FullTrust")

Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 3 of 3 (1,837 Views)

Re: Windows 7 .NET Security Permission

03-23-2012 08:52 AM in reply to: VB_Autocad_guy

Here's my code. Hope it helps someone else down the road. 

 

(Can't figure out how to get rid of the smiley faces.)

But they are ":smileyfrustrated:" colon and the letter S

 

 

Dim objShell 
Set objShell = CREATEOBJECT("Wscript.Shell")

'Change .NET Security Permissions to All Network path to FullTrust
'http://msdn.microsoft.com/en-us/library/cb6t8dtz(v=vs.80).aspx

'THE TRUSTED FOLDER IS SET HERE  'K:/SFARSTDS/Acad_Support/VB.NET/
objShell.run("%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -pp off -m -ag 1.2 -url file://K:/SFARSTDS/Acad_Support/VB.NET/* FullTrust")

'Modified objShell.run Path 
'Include %SYSTEMROOT% instead of "C:\WINNT" which is hard coded and depends on version of windows one is running. 



'This Sets a Flag for Autocad to Start the .NET DLL 
' Create a Registry Key


Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Autodesk\AutoCAD\R18.1\ACAD-9001:409\Applications\SFR"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath


' Create String and DWORD Values
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Autodesk\AutoCAD\R18.1\ACAD-9001:409\Applications\SFR"
strValueName = "DESCRIPTION"
strValue = "SFR"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "LOADCTRLS"
dwValue = 2
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

strValueName = "MANAGED"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

strKeyPath = "SOFTWARE\Autodesk\AutoCAD\R18.1\ACAD-9001:409\Applications\SFR"
strValueName = "LOADER"

'.NET DLL Path set here
strValue = "K:\SFARSTDS\Acad_Support\VB.NET\ClassAutocad2011.dll"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

 
'Instructions
' Load a .NET assembly

'After you have determined the build type of your .NET assembly, you must determine how it will be loaded into AutoCAD. 
'A .NET assembly file can be loaded manually or with demand loading.
'Manually - Use the NETLOAD command at the Command prompt or within an AutoLISP file. 
'For information on loading a .NET assembly with the NETLOAD command, see Load an Assembly into AutoCAD.
'Demand load - Define a key specific to the application you want to load when AutoCAD starts up. 
'The key must be placed under the Application key for the specific release of AutoCAD that you want your application to be loaded in.
'The key for the application can contain the following keys:
'DESCRIPTION
'Description of the .NET assemly and is optional.
'LOADCTRLS
'Controls how and when the .NET assembly is loaded.
'1 - Load application upon detection of proxy object
'2 - Load the application at startup
'4 - Load the application at start of a command
'8 - Load the application at the request of a user or another application
'16 - Do not load the application
'32 - Load the application transparently
'LOADER
'Specifies which .NET assembly file to load.
'MANAGED
'Specifies the file that should be loaded is a .NET assembly or ObjectARX file. Set to 1 for .NET assembly files.
'Demand load a .NET application

wscript.echo "Autocad 2011 - SFR Plugins Activated"

 

 

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.