all groups > dotnet security > june 2005 >
dotnet security :
Appdomain.CreateDomain throws SecurityException
Hi, The following exception occured when I tried to create an appdomain. "System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info) at StoredProcedures.SPInsertTest() The action that failed was: Demand The type of the first permission that failed was: System.Security.Permissions.SecurityPermission The Zone of the assembly that failed was: MyComputer " Let me explain what I have done. 1.I've created a class library by name TestApp which has a config file. I have method called Readconfig which reads from the config and puts the value in the file in some location. the readconfig method is called in the constructor of this class. 2. I've created an exe which refers the above calss libray and creates the object of the class present in it. 3. I've created a Managed stored procedure using the SQLServerProject in the whidbey. The stored procedure has the following code. AppDomainSetup ads = new AppDomainSetup(); ads.ApplicationBase = @"C:\SPTestExe"; ads.ConfigurationFile = @"C:\SPTestExe\TestAppExe.exe.config"; //AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); AppDomain ad = AppDomain.CurrentDomain; ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); when I install this stored procedure in yukon and run it, I get the above mentioned exception. Not able to trace out the reason. Can anyone tel me what the problem is??
SQL Server 2005 imposes additional permission restrictions on managed code that it hosts. For an introduction to this topic, take a look at the "CLR Integration Security" topic in the BOL. [quoted text, click to view] "Praisy" <Praisy@discussions.microsoft.com> wrote in message news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... > Hi, > The following exception occured when I tried to create an appdomain. > "System.Security.SecurityException: Request for the permission of type > 'System.Security.Permissions.SecurityPermission, mscorlib, > Version=2.0.0.0, > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. > at System.AppDomain.CreateDomain(String friendlyName, Evidence > securityInfo, AppDomainSetup info) > at StoredProcedures.SPInsertTest() > The action that failed was: > Demand > The type of the first permission that failed was: > System.Security.Permissions.SecurityPermission > The Zone of the assembly that failed was: > MyComputer " > > Let me explain what I have done. > > 1.I've created a class library by name TestApp which has a config file. I > have method called Readconfig which reads from the config and puts the > value > in the file in some location. the readconfig method is called in the > constructor of this class. > > 2. I've created an exe which refers the above calss libray and creates the > object of the class present in it. > > 3. I've created a Managed stored procedure using the SQLServerProject in > the > whidbey. The stored procedure has the following code. > > > AppDomainSetup ads = new AppDomainSetup(); > ads.ApplicationBase = @"C:\SPTestExe"; > ads.ConfigurationFile = @"C:\SPTestExe\TestAppExe.exe.config"; > > //AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); > AppDomain ad = AppDomain.CurrentDomain; > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); > > when I install this stored procedure in yukon and run it, I get the above > mentioned exception. > > Not able to trace out the reason. Can anyone tel me what the problem is?? > > Thanks,
Hi! Thanks for the info. While creating the assembly in SQLServer 2005, I had set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the security Exception. Now I changed to UNSAFE and got the TypeLoadException as follows. System.TypeLoadException: The domain manager specified by the host could not be instantiated. at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor) at System.AppDomainManager.CreateDomainHelper(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) at System.AppDomainManager.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info) at StoredProcedures.SPInsertTest() Any idea what can be the reason?? Thanks, [quoted text, click to view] "Nicole Calinoiu" wrote: > SQL Server 2005 imposes additional permission restrictions on managed code > that it hosts. For an introduction to this topic, take a look at the "CLR > Integration Security" topic in the BOL. > > > "Praisy" <Praisy@discussions.microsoft.com> wrote in message > news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... > > Hi, > > The following exception occured when I tried to create an appdomain. > > "System.Security.SecurityException: Request for the permission of type > > 'System.Security.Permissions.SecurityPermission, mscorlib, > > Version=2.0.0.0, > > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. > > at System.AppDomain.CreateDomain(String friendlyName, Evidence > > securityInfo, AppDomainSetup info) > > at StoredProcedures.SPInsertTest() > > The action that failed was: > > Demand > > The type of the first permission that failed was: > > System.Security.Permissions.SecurityPermission > > The Zone of the assembly that failed was: > > MyComputer " > > > > Let me explain what I have done. > > > > 1.I've created a class library by name TestApp which has a config file. I > > have method called Readconfig which reads from the config and puts the > > value > > in the file in some location. the readconfig method is called in the > > constructor of this class. > > > > 2. I've created an exe which refers the above calss libray and creates the > > object of the class present in it. > > > > 3. I've created a Managed stored procedure using the SQLServerProject in > > the > > whidbey. The stored procedure has the following code. > > > > > > AppDomainSetup ads = new AppDomainSetup(); > > ads.ApplicationBase = @"C:\SPTestExe"; > > ads.ConfigurationFile = @"C:\SPTestExe\TestAppExe.exe.config"; > > > > //AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); > > AppDomain ad = AppDomain.CurrentDomain; > > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); > > > > when I install this stored procedure in yukon and run it, I get the above > > mentioned exception. > > > > Not able to trace out the reason. Can anyone tel me what the problem is?? > > > > Thanks, > >
What is the code for the version of SPInsertTest that generates this exception? [quoted text, click to view] "Praisy" <Praisy@discussions.microsoft.com> wrote in message news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... > Hi! > Thanks for the info. While creating the assembly in SQLServer 2005, I had > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the security > Exception. Now I changed to UNSAFE and got the TypeLoadException as > follows. > > System.TypeLoadException: The domain manager specified by the host could > not > be instantiated. > at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup > setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, > IntPtr > parentSecurityDescriptor) > at System.AppDomainManager.CreateDomainHelper(String friendlyName, > Evidence securityInfo, AppDomainSetup appDomainInfo) > at System.AppDomainManager.CreateDomain(String friendlyName, Evidence > securityInfo, AppDomainSetup appDomainInfo) > at System.AppDomain.CreateDomain(String friendlyName, Evidence > securityInfo, AppDomainSetup info) > at StoredProcedures.SPInsertTest() > > Any idea what can be the reason?? > Thanks, > > > "Nicole Calinoiu" wrote: > >> SQL Server 2005 imposes additional permission restrictions on managed >> code >> that it hosts. For an introduction to this topic, take a look at the >> "CLR >> Integration Security" topic in the BOL. >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... >> > Hi, >> > The following exception occured when I tried to create an appdomain. >> > "System.Security.SecurityException: Request for the permission of type >> > 'System.Security.Permissions.SecurityPermission, mscorlib, >> > Version=2.0.0.0, >> > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence >> > securityInfo, AppDomainSetup info) >> > at StoredProcedures.SPInsertTest() >> > The action that failed was: >> > Demand >> > The type of the first permission that failed was: >> > System.Security.Permissions.SecurityPermission >> > The Zone of the assembly that failed was: >> > MyComputer " >> > >> > Let me explain what I have done. >> > >> > 1.I've created a class library by name TestApp which has a config file. >> > I >> > have method called Readconfig which reads from the config and puts the >> > value >> > in the file in some location. the readconfig method is called in the >> > constructor of this class. >> > >> > 2. I've created an exe which refers the above calss libray and creates >> > the >> > object of the class present in it. >> > >> > 3. I've created a Managed stored procedure using the SQLServerProject >> > in >> > the >> > whidbey. The stored procedure has the following code. >> > >> > >> > AppDomainSetup ads = new AppDomainSetup(); >> > ads.ApplicationBase = @"C:\SPTestExe"; >> > ads.ConfigurationFile = >> > @"C:\SPTestExe\TestAppExe.exe.config"; >> > >> > //AppDomain ad = AppDomain.CreateDomain("TestApp", null, >> > ads); >> > AppDomain ad = AppDomain.CurrentDomain; >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); >> > >> > when I install this stored procedure in yukon and run it, I get the >> > above >> > mentioned exception. >> > >> > Not able to trace out the reason. Can anyone tel me what the problem >> > is?? >> > >> > Thanks, >> >> >>
Hi Nicole, Follwoing is the code that generates this exception public static void SPInsertTest() { AppDomainSetup ads = new AppDomainSetup(); ads.ApplicationBase = @"C:\SPTestExe"; ads.ConfigurationFile = @"C:\SPTestExe\TestAppExe.exe.config"; AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); } [quoted text, click to view] "Nicole Calinoiu" wrote: > What is the code for the version of SPInsertTest that generates this > exception? > > > "Praisy" <Praisy@discussions.microsoft.com> wrote in message > news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... > > Hi! > > Thanks for the info. While creating the assembly in SQLServer 2005, I had > > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the security > > Exception. Now I changed to UNSAFE and got the TypeLoadException as > > follows. > > > > System.TypeLoadException: The domain manager specified by the host could > > not > > be instantiated. > > at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup > > setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, > > IntPtr > > parentSecurityDescriptor) > > at System.AppDomainManager.CreateDomainHelper(String friendlyName, > > Evidence securityInfo, AppDomainSetup appDomainInfo) > > at System.AppDomainManager.CreateDomain(String friendlyName, Evidence > > securityInfo, AppDomainSetup appDomainInfo) > > at System.AppDomain.CreateDomain(String friendlyName, Evidence > > securityInfo, AppDomainSetup info) > > at StoredProcedures.SPInsertTest() > > > > Any idea what can be the reason?? > > Thanks, > > > > > > "Nicole Calinoiu" wrote: > > > >> SQL Server 2005 imposes additional permission restrictions on managed > >> code > >> that it hosts. For an introduction to this topic, take a look at the > >> "CLR > >> Integration Security" topic in the BOL. > >> > >> > >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... > >> > Hi, > >> > The following exception occured when I tried to create an appdomain. > >> > "System.Security.SecurityException: Request for the permission of type > >> > 'System.Security.Permissions.SecurityPermission, mscorlib, > >> > Version=2.0.0.0, > >> > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. > >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence > >> > securityInfo, AppDomainSetup info) > >> > at StoredProcedures.SPInsertTest() > >> > The action that failed was: > >> > Demand > >> > The type of the first permission that failed was: > >> > System.Security.Permissions.SecurityPermission > >> > The Zone of the assembly that failed was: > >> > MyComputer " > >> > > >> > Let me explain what I have done. > >> > > >> > 1.I've created a class library by name TestApp which has a config file. > >> > I > >> > have method called Readconfig which reads from the config and puts the > >> > value > >> > in the file in some location. the readconfig method is called in the > >> > constructor of this class. > >> > > >> > 2. I've created an exe which refers the above calss libray and creates > >> > the > >> > object of the class present in it. > >> > > >> > 3. I've created a Managed stored procedure using the SQLServerProject > >> > in > >> > the > >> > whidbey. The stored procedure has the following code. > >> > > >> > > >> > AppDomainSetup ads = new AppDomainSetup(); > >> > ads.ApplicationBase = @"C:\SPTestExe"; > >> > ads.ConfigurationFile = > >> > @"C:\SPTestExe\TestAppExe.exe.config"; > >> > > >> > //AppDomain ad = AppDomain.CreateDomain("TestApp", null, > >> > ads); > >> > AppDomain ad = AppDomain.CurrentDomain; > >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); > >> > > >> > when I install this stored procedure in yukon and run it, I get the > >> > above > >> > mentioned exception. > >> > > >> > Not able to trace out the reason. Can anyone tel me what the problem > >> > is?? > >> > > >> > Thanks, > >> > >> > >> > >
Even if you could get past this exception, you would block on the next line since the SQL CLR host blocks the necessary call. Might it be possible to alter your target assembly so that the call can be made as a simple method invocation? [quoted text, click to view] "Praisy" <Praisy@discussions.microsoft.com> wrote in message news:107A2752-4FDE-43B5-86D2-3506052BB057@microsoft.com... > Hi Nicole, > Follwoing is the code that generates this exception > > public static void SPInsertTest() > { > AppDomainSetup ads = new AppDomainSetup(); > ads.ApplicationBase = @"C:\SPTestExe"; > ads.ConfigurationFile = @"C:\SPTestExe\TestAppExe.exe.config"; > AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); > } > > "Nicole Calinoiu" wrote: > >> What is the code for the version of SPInsertTest that generates this >> exception? >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... >> > Hi! >> > Thanks for the info. While creating the assembly in SQLServer 2005, I >> > had >> > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the >> > security >> > Exception. Now I changed to UNSAFE and got the TypeLoadException as >> > follows. >> > >> > System.TypeLoadException: The domain manager specified by the host >> > could >> > not >> > be instantiated. >> > at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup >> > setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, >> > IntPtr >> > parentSecurityDescriptor) >> > at System.AppDomainManager.CreateDomainHelper(String friendlyName, >> > Evidence securityInfo, AppDomainSetup appDomainInfo) >> > at System.AppDomainManager.CreateDomain(String friendlyName, Evidence >> > securityInfo, AppDomainSetup appDomainInfo) >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence >> > securityInfo, AppDomainSetup info) >> > at StoredProcedures.SPInsertTest() >> > >> > Any idea what can be the reason?? >> > Thanks, >> > >> > >> > "Nicole Calinoiu" wrote: >> > >> >> SQL Server 2005 imposes additional permission restrictions on managed >> >> code >> >> that it hosts. For an introduction to this topic, take a look at the >> >> "CLR >> >> Integration Security" topic in the BOL. >> >> >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... >> >> > Hi, >> >> > The following exception occured when I tried to create an appdomain. >> >> > "System.Security.SecurityException: Request for the permission of >> >> > type >> >> > 'System.Security.Permissions.SecurityPermission, mscorlib, >> >> > Version=2.0.0.0, >> >> > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. >> >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence >> >> > securityInfo, AppDomainSetup info) >> >> > at StoredProcedures.SPInsertTest() >> >> > The action that failed was: >> >> > Demand >> >> > The type of the first permission that failed was: >> >> > System.Security.Permissions.SecurityPermission >> >> > The Zone of the assembly that failed was: >> >> > MyComputer " >> >> > >> >> > Let me explain what I have done. >> >> > >> >> > 1.I've created a class library by name TestApp which has a config >> >> > file. >> >> > I >> >> > have method called Readconfig which reads from the config and puts >> >> > the >> >> > value >> >> > in the file in some location. the readconfig method is called in the >> >> > constructor of this class. >> >> > >> >> > 2. I've created an exe which refers the above calss libray and >> >> > creates >> >> > the >> >> > object of the class present in it. >> >> > >> >> > 3. I've created a Managed stored procedure using the >> >> > SQLServerProject >> >> > in >> >> > the >> >> > whidbey. The stored procedure has the following code. >> >> > >> >> > >> >> > AppDomainSetup ads = new AppDomainSetup(); >> >> > ads.ApplicationBase = @"C:\SPTestExe"; >> >> > ads.ConfigurationFile = >> >> > @"C:\SPTestExe\TestAppExe.exe.config"; >> >> > >> >> > //AppDomain ad = AppDomain.CreateDomain("TestApp", null, >> >> > ads); >> >> > AppDomain ad = AppDomain.CurrentDomain; >> >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); >> >> > >> >> > when I install this stored procedure in yukon and run it, I get the >> >> > above >> >> > mentioned exception. >> >> > >> >> > Not able to trace out the reason. Can anyone tel me what the problem >> >> > is?? >> >> > >> >> > Thanks, >> >> >> >> >> >> >> >> >>
Let me explain my problem more clearly. I have a set of dlls which read from a config file. When I reference these dlls in any application, I need to provide a config file with the values required by the dlls I reference. Now, I want to perform a set of operations using the above said dlls in a managed stored procedure. since I cannot provide a config file in managed stored proceudre, I did the follwoing. 1. Created an exe which references the set of dlls and which provides a config file for the same. 2. In the managed stored procedure, I create an appdomain and execute the assembly in the appdomain created. Is it possible to create appdomains in the managed stored procedure? As I have explained my problem above, is there any other way to do this? Your help is highly appreciated. Thanks in advance, [quoted text, click to view] "Nicole Calinoiu" wrote: > Even if you could get past this exception, you would block on the next line > since the SQL CLR host blocks the necessary call. Might it be possible to > alter your target assembly so that the call can be made as a simple method > invocation? > > > > "Praisy" <Praisy@discussions.microsoft.com> wrote in message > news:107A2752-4FDE-43B5-86D2-3506052BB057@microsoft.com... > > Hi Nicole, > > Follwoing is the code that generates this exception > > > > public static void SPInsertTest() > > { > > AppDomainSetup ads = new AppDomainSetup(); > > ads.ApplicationBase = @"C:\SPTestExe"; > > ads.ConfigurationFile = @"C:\SPTestExe\TestAppExe.exe.config"; > > AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); > > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); > > } > > > > "Nicole Calinoiu" wrote: > > > >> What is the code for the version of SPInsertTest that generates this > >> exception? > >> > >> > >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... > >> > Hi! > >> > Thanks for the info. While creating the assembly in SQLServer 2005, I > >> > had > >> > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the > >> > security > >> > Exception. Now I changed to UNSAFE and got the TypeLoadException as > >> > follows. > >> > > >> > System.TypeLoadException: The domain manager specified by the host > >> > could > >> > not > >> > be instantiated. > >> > at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup > >> > setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, > >> > IntPtr > >> > parentSecurityDescriptor) > >> > at System.AppDomainManager.CreateDomainHelper(String friendlyName, > >> > Evidence securityInfo, AppDomainSetup appDomainInfo) > >> > at System.AppDomainManager.CreateDomain(String friendlyName, Evidence > >> > securityInfo, AppDomainSetup appDomainInfo) > >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence > >> > securityInfo, AppDomainSetup info) > >> > at StoredProcedures.SPInsertTest() > >> > > >> > Any idea what can be the reason?? > >> > Thanks, > >> > > >> > > >> > "Nicole Calinoiu" wrote: > >> > > >> >> SQL Server 2005 imposes additional permission restrictions on managed > >> >> code > >> >> that it hosts. For an introduction to this topic, take a look at the > >> >> "CLR > >> >> Integration Security" topic in the BOL. > >> >> > >> >> > >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> >> news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... > >> >> > Hi, > >> >> > The following exception occured when I tried to create an appdomain. > >> >> > "System.Security.SecurityException: Request for the permission of > >> >> > type > >> >> > 'System.Security.Permissions.SecurityPermission, mscorlib, > >> >> > Version=2.0.0.0, > >> >> > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. > >> >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence > >> >> > securityInfo, AppDomainSetup info) > >> >> > at StoredProcedures.SPInsertTest() > >> >> > The action that failed was: > >> >> > Demand > >> >> > The type of the first permission that failed was: > >> >> > System.Security.Permissions.SecurityPermission > >> >> > The Zone of the assembly that failed was: > >> >> > MyComputer " > >> >> > > >> >> > Let me explain what I have done. > >> >> > > >> >> > 1.I've created a class library by name TestApp which has a config > >> >> > file. > >> >> > I > >> >> > have method called Readconfig which reads from the config and puts > >> >> > the > >> >> > value > >> >> > in the file in some location. the readconfig method is called in the > >> >> > constructor of this class. > >> >> > > >> >> > 2. I've created an exe which refers the above calss libray and > >> >> > creates > >> >> > the > >> >> > object of the class present in it. > >> >> > > >> >> > 3. I've created a Managed stored procedure using the > >> >> > SQLServerProject > >> >> > in > >> >> > the > >> >> > whidbey. The stored procedure has the following code. > >> >> > > >> >> > > >> >> > AppDomainSetup ads = new AppDomainSetup(); > >> >> > ads.ApplicationBase = @"C:\SPTestExe"; > >> >> > ads.ConfigurationFile = > >> >> > @"C:\SPTestExe\TestAppExe.exe.config"; > >> >> > > >> >> > //AppDomain ad = AppDomain.CreateDomain("TestApp", null, > >> >> > ads); > >> >> > AppDomain ad = AppDomain.CurrentDomain; > >> >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); > >> >> > > >> >> > when I install this stored procedure in yukon and run it, I get the > >> >> > above > >> >> > mentioned exception. > >> >> > > >> >> > Not able to trace out the reason. Can anyone tel me what the problem > >> >> > is?? > >> >> > > >> >> > Thanks, > >> >> > >> >> > >> >> > >> > >> > >> > >
[quoted text, click to view] "Praisy" <Praisy@discussions.microsoft.com> wrote in message news:B18265E8-0152-4E87-8278-147945E8DDAC@microsoft.com... <snip> > Is it possible to create appdomains in the managed stored procedure?
From what I've seen written about the SQL CLR hosting model, I would guess that the designers' intent is probably to prevent any creation of app domains by user code. However, the official documentation is quite vague on this topic, so you might want to ask about it in the beta newsgroups at http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&slcid=us. [quoted text, click to view] > As I have explained my problem above, is there any other way to do this?
If you are the author of the target DLLs, the cleanest approach might be to modify the DLLs so that they can read the relevant data from a source specified by the caller, falling back to the default config file if no other source is specified. If this isn't an option, would launching the exe via System.Diagnostics.Process.Start offer sufficient control for your purposes? [quoted text, click to view] > Your help is highly appreciated. > Thanks in advance, > > "Nicole Calinoiu" wrote: > >> Even if you could get past this exception, you would block on the next >> line >> since the SQL CLR host blocks the necessary call. Might it be possible >> to >> alter your target assembly so that the call can be made as a simple >> method >> invocation? >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> news:107A2752-4FDE-43B5-86D2-3506052BB057@microsoft.com... >> > Hi Nicole, >> > Follwoing is the code that generates this exception >> > >> > public static void SPInsertTest() >> > { >> > AppDomainSetup ads = new AppDomainSetup(); >> > ads.ApplicationBase = @"C:\SPTestExe"; >> > ads.ConfigurationFile = @"C:\SPTestExe\TestAppExe.exe.config"; >> > AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); >> > } >> > >> > "Nicole Calinoiu" wrote: >> > >> >> What is the code for the version of SPInsertTest that generates this >> >> exception? >> >> >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... >> >> > Hi! >> >> > Thanks for the info. While creating the assembly in SQLServer 2005, >> >> > I >> >> > had >> >> > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the >> >> > security >> >> > Exception. Now I changed to UNSAFE and got the TypeLoadException as >> >> > follows. >> >> > >> >> > System.TypeLoadException: The domain manager specified by the host >> >> > could >> >> > not >> >> > be instantiated. >> >> > at System.AppDomain.nCreateDomain(String friendlyName, >> >> > AppDomainSetup >> >> > setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, >> >> > IntPtr >> >> > parentSecurityDescriptor) >> >> > at System.AppDomainManager.CreateDomainHelper(String friendlyName, >> >> > Evidence securityInfo, AppDomainSetup appDomainInfo) >> >> > at System.AppDomainManager.CreateDomain(String friendlyName, >> >> > Evidence >> >> > securityInfo, AppDomainSetup appDomainInfo) >> >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence >> >> > securityInfo, AppDomainSetup info) >> >> > at StoredProcedures.SPInsertTest() >> >> > >> >> > Any idea what can be the reason?? >> >> > Thanks, >> >> > >> >> > >> >> > "Nicole Calinoiu" wrote: >> >> > >> >> >> SQL Server 2005 imposes additional permission restrictions on >> >> >> managed >> >> >> code >> >> >> that it hosts. For an introduction to this topic, take a look at >> >> >> the >> >> >> "CLR >> >> >> Integration Security" topic in the BOL. >> >> >> >> >> >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> >> news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... >> >> >> > Hi, >> >> >> > The following exception occured when I tried to create an >> >> >> > appdomain. >> >> >> > "System.Security.SecurityException: Request for the permission of >> >> >> > type >> >> >> > 'System.Security.Permissions.SecurityPermission, mscorlib, >> >> >> > Version=2.0.0.0, >> >> >> > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. >> >> >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence >> >> >> > securityInfo, AppDomainSetup info) >> >> >> > at StoredProcedures.SPInsertTest() >> >> >> > The action that failed was: >> >> >> > Demand >> >> >> > The type of the first permission that failed was: >> >> >> > System.Security.Permissions.SecurityPermission >> >> >> > The Zone of the assembly that failed was: >> >> >> > MyComputer " >> >> >> > >> >> >> > Let me explain what I have done. >> >> >> > >> >> >> > 1.I've created a class library by name TestApp which has a config >> >> >> > file. >> >> >> > I >> >> >> > have method called Readconfig which reads from the config and >> >> >> > puts >> >> >> > the >> >> >> > value >> >> >> > in the file in some location. the readconfig method is called in >> >> >> > the >> >> >> > constructor of this class. >> >> >> > >> >> >> > 2. I've created an exe which refers the above calss libray and >> >> >> > creates >> >> >> > the >> >> >> > object of the class present in it. >> >> >> > >> >> >> > 3. I've created a Managed stored procedure using the >> >> >> > SQLServerProject >> >> >> > in >> >> >> > the >> >> >> > whidbey. The stored procedure has the following code. >> >> >> > >> >> >> > >> >> >> > AppDomainSetup ads = new AppDomainSetup(); >> >> >> > ads.ApplicationBase = @"C:\SPTestExe"; >> >> >> > ads.ConfigurationFile = >> >> >> > @"C:\SPTestExe\TestAppExe.exe.config"; >> >> >> > >> >> >> > //AppDomain ad = AppDomain.CreateDomain("TestApp", >> >> >> > null, >> >> >> > ads); >> >> >> > AppDomain ad = AppDomain.CurrentDomain; >> >> >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); >> >> >> > >> >> >> > when I install this stored procedure in yukon and run it, I get >> >> >> > the >> >> >> > above >> >> >> > mentioned exception. >> >> >> > >> >> >> > Not able to trace out the reason. Can anyone tel me what the >> >> >> > problem >> >> >> > is?? >> >> >> > >> >> >> > Thanks, >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
Nicole, Thanks for the link.. I'l post this question to the beta newsgroups that you mentioned. I tried using System.diagnostics.Process.Start() which threw SecurityException as follows System.Security.SecurityException: Request failed. System.Security.SecurityException: at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action) at StoredProcedures.SPInsertTest() [quoted text, click to view] "Nicole Calinoiu" wrote: > "Praisy" <Praisy@discussions.microsoft.com> wrote in message > news:B18265E8-0152-4E87-8278-147945E8DDAC@microsoft.com... > <snip> > > Is it possible to create appdomains in the managed stored procedure? > > From what I've seen written about the SQL CLR hosting model, I would guess > that the designers' intent is probably to prevent any creation of app > domains by user code. However, the official documentation is quite vague on > this topic, so you might want to ask about it in the beta newsgroups at > http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&slcid=us. > > > > As I have explained my problem above, is there any other way to do this? > > If you are the author of the target DLLs, the cleanest approach might be to > modify the DLLs so that they can read the relevant data from a source > specified by the caller, falling back to the default config file if no other > source is specified. If this isn't an option, would launching the exe via > System.Diagnostics.Process.Start offer sufficient control for your purposes? > > > > > Your help is highly appreciated. > > Thanks in advance, > > > > "Nicole Calinoiu" wrote: > > > >> Even if you could get past this exception, you would block on the next > >> line > >> since the SQL CLR host blocks the necessary call. Might it be possible > >> to > >> alter your target assembly so that the call can be made as a simple > >> method > >> invocation? > >> > >> > >> > >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> news:107A2752-4FDE-43B5-86D2-3506052BB057@microsoft.com... > >> > Hi Nicole, > >> > Follwoing is the code that generates this exception > >> > > >> > public static void SPInsertTest() > >> > { > >> > AppDomainSetup ads = new AppDomainSetup(); > >> > ads.ApplicationBase = @"C:\SPTestExe"; > >> > ads.ConfigurationFile = @"C:\SPTestExe\TestAppExe.exe.config"; > >> > AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); > >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); > >> > } > >> > > >> > "Nicole Calinoiu" wrote: > >> > > >> >> What is the code for the version of SPInsertTest that generates this > >> >> exception? > >> >> > >> >> > >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> >> news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... > >> >> > Hi! > >> >> > Thanks for the info. While creating the assembly in SQLServer 2005, > >> >> > I > >> >> > had > >> >> > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the > >> >> > security > >> >> > Exception. Now I changed to UNSAFE and got the TypeLoadException as > >> >> > follows. > >> >> > > >> >> > System.TypeLoadException: The domain manager specified by the host > >> >> > could > >> >> > not > >> >> > be instantiated. > >> >> > at System.AppDomain.nCreateDomain(String friendlyName, > >> >> > AppDomainSetup > >> >> > setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, > >> >> > IntPtr > >> >> > parentSecurityDescriptor) > >> >> > at System.AppDomainManager.CreateDomainHelper(String friendlyName, > >> >> > Evidence securityInfo, AppDomainSetup appDomainInfo) > >> >> > at System.AppDomainManager.CreateDomain(String friendlyName, > >> >> > Evidence > >> >> > securityInfo, AppDomainSetup appDomainInfo) > >> >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence > >> >> > securityInfo, AppDomainSetup info) > >> >> > at StoredProcedures.SPInsertTest() > >> >> > > >> >> > Any idea what can be the reason?? > >> >> > Thanks, > >> >> > > >> >> > > >> >> > "Nicole Calinoiu" wrote: > >> >> > > >> >> >> SQL Server 2005 imposes additional permission restrictions on > >> >> >> managed > >> >> >> code > >> >> >> that it hosts. For an introduction to this topic, take a look at > >> >> >> the > >> >> >> "CLR > >> >> >> Integration Security" topic in the BOL. > >> >> >> > >> >> >> > >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> >> >> news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... > >> >> >> > Hi, > >> >> >> > The following exception occured when I tried to create an > >> >> >> > appdomain. > >> >> >> > "System.Security.SecurityException: Request for the permission of > >> >> >> > type > >> >> >> > 'System.Security.Permissions.SecurityPermission, mscorlib, > >> >> >> > Version=2.0.0.0, > >> >> >> > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. > >> >> >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence > >> >> >> > securityInfo, AppDomainSetup info) > >> >> >> > at StoredProcedures.SPInsertTest() > >> >> >> > The action that failed was: > >> >> >> > Demand > >> >> >> > The type of the first permission that failed was: > >> >> >> > System.Security.Permissions.SecurityPermission > >> >> >> > The Zone of the assembly that failed was: > >> >> >> > MyComputer " > >> >> >> > > >> >> >> > Let me explain what I have done. > >> >> >> > > >> >> >> > 1.I've created a class library by name TestApp which has a config > >> >> >> > file. > >> >> >> > I > >> >> >> > have method called Readconfig which reads from the config and > >> >> >> > puts > >> >> >> > the > >> >> >> > value > >> >> >> > in the file in some location. the readconfig method is called in > >> >> >> > the > >> >> >> > constructor of this class. > >> >> >> > > >> >> >> > 2. I've created an exe which refers the above calss libray and > >> >> >> > creates > >> >> >> > the > >> >> >> > object of the class present in it. > >> >> >> >
You'll need to run at the unsafe level to call Process.Start successfully. [quoted text, click to view] "Praisy" <Praisy@discussions.microsoft.com> wrote in message news:8C1D9EBF-D9D0-44FF-81F4-98F68F386F88@microsoft.com... > Nicole, > Thanks for the link.. I'l post this question to the beta newsgroups that > you > mentioned. > I tried using System.diagnostics.Process.Start() which threw > SecurityException as follows > > System.Security.SecurityException: Request failed. > System.Security.SecurityException: > at > System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly > asm, > PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, > SecurityAction action, Object demand, IPermission permThatFailed) > at > System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object > assemblyOrString, PermissionSet granted, PermissionSet refused, > RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission > permThatFailed) > at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet > grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle > rmh, Object assemblyOrString, SecurityAction action, Boolean > throwException) > at > System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack > cs, > PermissionSet grants, PermissionSet refused, PermissionSet demands, > RuntimeMethodHandle rmh, Assembly asm, SecurityAction action) > at StoredProcedures.SPInsertTest() > > "Nicole Calinoiu" wrote: > >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> news:B18265E8-0152-4E87-8278-147945E8DDAC@microsoft.com... >> <snip> >> > Is it possible to create appdomains in the managed stored procedure? >> >> From what I've seen written about the SQL CLR hosting model, I would >> guess >> that the designers' intent is probably to prevent any creation of app >> domains by user code. However, the official documentation is quite vague >> on >> this topic, so you might want to ask about it in the beta newsgroups at >> http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&slcid=us. >> >> >> > As I have explained my problem above, is there any other way to do >> > this? >> >> If you are the author of the target DLLs, the cleanest approach might be >> to >> modify the DLLs so that they can read the relevant data from a source >> specified by the caller, falling back to the default config file if no >> other >> source is specified. If this isn't an option, would launching the exe >> via >> System.Diagnostics.Process.Start offer sufficient control for your >> purposes? >> >> >> >> > Your help is highly appreciated. >> > Thanks in advance, >> > >> > "Nicole Calinoiu" wrote: >> > >> >> Even if you could get past this exception, you would block on the next >> >> line >> >> since the SQL CLR host blocks the necessary call. Might it be >> >> possible >> >> to >> >> alter your target assembly so that the call can be made as a simple >> >> method >> >> invocation? >> >> >> >> >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> news:107A2752-4FDE-43B5-86D2-3506052BB057@microsoft.com... >> >> > Hi Nicole, >> >> > Follwoing is the code that generates this exception >> >> > >> >> > public static void SPInsertTest() >> >> > { >> >> > AppDomainSetup ads = new AppDomainSetup(); >> >> > ads.ApplicationBase = @"C:\SPTestExe"; >> >> > ads.ConfigurationFile = >> >> > @"C:\SPTestExe\TestAppExe.exe.config"; >> >> > AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); >> >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); >> >> > } >> >> > >> >> > "Nicole Calinoiu" wrote: >> >> > >> >> >> What is the code for the version of SPInsertTest that generates >> >> >> this >> >> >> exception? >> >> >> >> >> >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> >> news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... >> >> >> > Hi! >> >> >> > Thanks for the info. While creating the assembly in SQLServer >> >> >> > 2005, >> >> >> > I >> >> >> > had >> >> >> > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the >> >> >> > security >> >> >> > Exception. Now I changed to UNSAFE and got the TypeLoadException >> >> >> > as >> >> >> > follows. >> >> >> > >> >> >> > System.TypeLoadException: The domain manager specified by the >> >> >> > host >> >> >> > could >> >> >> > not >> >> >> > be instantiated. >> >> >> > at System.AppDomain.nCreateDomain(String friendlyName, >> >> >> > AppDomainSetup >> >> >> > setup, Evidence providedSecurityInfo, Evidence >> >> >> > creatorsSecurityInfo, >> >> >> > IntPtr >> >> >> > parentSecurityDescriptor) >> >> >> > at System.AppDomainManager.CreateDomainHelper(String >> >> >> > friendlyName, >> >> >> > Evidence securityInfo, AppDomainSetup appDomainInfo) >> >> >> > at System.AppDomainManager.CreateDomain(String friendlyName, >> >> >> > Evidence >> >> >> > securityInfo, AppDomainSetup appDomainInfo) >> >> >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence >> >> >> > securityInfo, AppDomainSetup info) >> >> >> > at StoredProcedures.SPInsertTest() >> >> >> > >> >> >> > Any idea what can be the reason?? >> >> >> > Thanks, >> >> >> > >> >> >> > >> >> >> > "Nicole Calinoiu" wrote: >> >> >> > >> >> >> >> SQL Server 2005 imposes additional permission restrictions on >> >> >> >> managed >> >> >> >> code >> >> >> >> that it hosts. For an introduction to this topic, take a look >> >> >> >> at >> >> >> >> the >> >> >> >> "CLR >> >> >> >> Integration Security" topic in the BOL. >> >> >> >> >> >> >> >> >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> >> >> news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... >> >> >> >> > Hi, >> >> >> >> > The following exception occured when I tried to create an >> >> >> >> > appdomain. >> >> >> >> > "System.Security.SecurityException: Request for the permission >> >> >> >> > of >> >> >> >> > type >> >> >> >> > 'System.Security.Permissions.SecurityPermission, mscorlib, >> >> >> >> > Version=2.0.0.0, >> >> >> >> > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. >> >> >> >> > at System.AppDomain.CreateDomain(String friendlyName, >> >> >> >> > Evidence >> >> >> >> > securityInfo, AppDomainSetup info) >> >> >> >> > at StoredProcedures.SPInsertTest() >> >> >> >> > The action that failed was: >> >> >> >> > Demand >> >> >> >> > The type of the first permission that failed was: >> >> >> >> > System.Security.Permissions.SecurityPermission >> >> >> >> > The Zone of the assembly that failed was: >> >> >> >> > MyComputer " >> >> >> >> > >> >> >> >> > Let me explain what I have done. >> >> >> >> > >> >> >> >> > 1.I've created a class library by name TestApp which has a >> >> >> >> > config
Yes, my problem got solved with process.start. I wonder if this is the recomended solution. are there any drawbacks with this approach?? [quoted text, click to view] "Nicole Calinoiu" wrote: > You'll need to run at the unsafe level to call Process.Start successfully. > > > "Praisy" <Praisy@discussions.microsoft.com> wrote in message > news:8C1D9EBF-D9D0-44FF-81F4-98F68F386F88@microsoft.com... > > Nicole, > > Thanks for the link.. I'l post this question to the beta newsgroups that > > you > > mentioned. > > I tried using System.diagnostics.Process.Start() which threw > > SecurityException as follows > > > > System.Security.SecurityException: Request failed. > > System.Security.SecurityException: > > at > > System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly > > asm, > > PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, > > SecurityAction action, Object demand, IPermission permThatFailed) > > at > > System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object > > assemblyOrString, PermissionSet granted, PermissionSet refused, > > RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission > > permThatFailed) > > at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet > > grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle > > rmh, Object assemblyOrString, SecurityAction action, Boolean > > throwException) > > at > > System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack > > cs, > > PermissionSet grants, PermissionSet refused, PermissionSet demands, > > RuntimeMethodHandle rmh, Assembly asm, SecurityAction action) > > at StoredProcedures.SPInsertTest() > > > > "Nicole Calinoiu" wrote: > > > >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> news:B18265E8-0152-4E87-8278-147945E8DDAC@microsoft.com... > >> <snip> > >> > Is it possible to create appdomains in the managed stored procedure? > >> > >> From what I've seen written about the SQL CLR hosting model, I would > >> guess > >> that the designers' intent is probably to prevent any creation of app > >> domains by user code. However, the official documentation is quite vague > >> on > >> this topic, so you might want to ask about it in the beta newsgroups at > >> http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&slcid=us. > >> > >> > >> > As I have explained my problem above, is there any other way to do > >> > this? > >> > >> If you are the author of the target DLLs, the cleanest approach might be > >> to > >> modify the DLLs so that they can read the relevant data from a source > >> specified by the caller, falling back to the default config file if no > >> other > >> source is specified. If this isn't an option, would launching the exe > >> via > >> System.Diagnostics.Process.Start offer sufficient control for your > >> purposes? > >> > >> > >> > >> > Your help is highly appreciated. > >> > Thanks in advance, > >> > > >> > "Nicole Calinoiu" wrote: > >> > > >> >> Even if you could get past this exception, you would block on the next > >> >> line > >> >> since the SQL CLR host blocks the necessary call. Might it be > >> >> possible > >> >> to > >> >> alter your target assembly so that the call can be made as a simple > >> >> method > >> >> invocation? > >> >> > >> >> > >> >> > >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> >> news:107A2752-4FDE-43B5-86D2-3506052BB057@microsoft.com... > >> >> > Hi Nicole, > >> >> > Follwoing is the code that generates this exception > >> >> > > >> >> > public static void SPInsertTest() > >> >> > { > >> >> > AppDomainSetup ads = new AppDomainSetup(); > >> >> > ads.ApplicationBase = @"C:\SPTestExe"; > >> >> > ads.ConfigurationFile = > >> >> > @"C:\SPTestExe\TestAppExe.exe.config"; > >> >> > AppDomain ad = AppDomain.CreateDomain("TestApp", null, ads); > >> >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); > >> >> > } > >> >> > > >> >> > "Nicole Calinoiu" wrote: > >> >> > > >> >> >> What is the code for the version of SPInsertTest that generates > >> >> >> this > >> >> >> exception? > >> >> >> > >> >> >> > >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> >> >> news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... > >> >> >> > Hi! > >> >> >> > Thanks for the info. While creating the assembly in SQLServer > >> >> >> > 2005, > >> >> >> > I > >> >> >> > had > >> >> >> > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got the > >> >> >> > security > >> >> >> > Exception. Now I changed to UNSAFE and got the TypeLoadException > >> >> >> > as > >> >> >> > follows. > >> >> >> > > >> >> >> > System.TypeLoadException: The domain manager specified by the > >> >> >> > host > >> >> >> > could > >> >> >> > not > >> >> >> > be instantiated. > >> >> >> > at System.AppDomain.nCreateDomain(String friendlyName, > >> >> >> > AppDomainSetup > >> >> >> > setup, Evidence providedSecurityInfo, Evidence > >> >> >> > creatorsSecurityInfo, > >> >> >> > IntPtr > >> >> >> > parentSecurityDescriptor) > >> >> >> > at System.AppDomainManager.CreateDomainHelper(String > >> >> >> > friendlyName, > >> >> >> > Evidence securityInfo, AppDomainSetup appDomainInfo) > >> >> >> > at System.AppDomainManager.CreateDomain(String friendlyName, > >> >> >> > Evidence > >> >> >> > securityInfo, AppDomainSetup appDomainInfo) > >> >> >> > at System.AppDomain.CreateDomain(String friendlyName, Evidence > >> >> >> > securityInfo, AppDomainSetup info) > >> >> >> > at StoredProcedures.SPInsertTest() > >> >> >> > > >> >> >> > Any idea what can be the reason?? > >> >> >> > Thanks, > >> >> >> > > >> >> >> > > >> >> >> > "Nicole Calinoiu" wrote: > >> >> >> > > >> >> >> >> SQL Server 2005 imposes additional permission restrictions on > >> >> >> >> managed > >> >> >> >> code > >> >> >> >> that it hosts. For an introduction to this topic, take a look > >> >> >> >> at > >> >> >> >> the > >> >> >> >> "CLR > >> >> >> >> Integration Security" topic in the BOL. > >> >> >> >> > >> >> >> >> > >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message > >> >> >> >> news:42EA4E5E-0B83-4EF3-9E0C-A74CA51A1BB0@microsoft.com... > >> >> >> >> > Hi, > >> >> >> >> > The following exception occured when I tried to create an > >> >> >> >> > appdomain. > >> >> >> >> > "System.Security.SecurityException: Request for the permission > >> >> >> >> > of > >> >> >> >> > type > >> >> >> >> > 'System.Security.Permissions.SecurityPermission, mscorlib, > >> >> >> >> > Version=2.0.0.0, > >> >> >> >> > Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. > >> >> >> >> > at System.AppDomain.CreateDomain(String friendlyName, > >> >> >> >> > Evidence > >> >> >> >> > securityInfo, AppDomainSetup info)
[quoted text, click to view] "Praisy" <Praisy@discussions.microsoft.com> wrote in message news:449E2944-ED52-4C95-AD60-4FC2DAAC1E95@microsoft.com... > Yes, my problem got solved with process.start. > I wonder if this is the recomended solution. > are there any drawbacks with this approach??
You would probably have better luck with this question in a SQL Server newsgroup. That said, some obvious problems would include: 1. Communication of any success or failure messages back to the calling code will be somewhat inconvenient. 2. Waiting on the external process may cause some unanticipated problems with your stored procedure performance. 3. Launching the external process may be quite costly, so it's probably not a good choice if the stored procedure is called often from client code. [quoted text, click to view] > > "Nicole Calinoiu" wrote: > >> You'll need to run at the unsafe level to call Process.Start >> successfully. >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> news:8C1D9EBF-D9D0-44FF-81F4-98F68F386F88@microsoft.com... >> > Nicole, >> > Thanks for the link.. I'l post this question to the beta newsgroups >> > that >> > you >> > mentioned. >> > I tried using System.diagnostics.Process.Start() which threw >> > SecurityException as follows >> > >> > System.Security.SecurityException: Request failed. >> > System.Security.SecurityException: >> > at >> > System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly >> > asm, >> > PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, >> > SecurityAction action, Object demand, IPermission permThatFailed) >> > at >> > System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object >> > assemblyOrString, PermissionSet granted, PermissionSet refused, >> > RuntimeMethodHandle rmh, SecurityAction action, Object demand, >> > IPermission >> > permThatFailed) >> > at >> > System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet >> > grants, PermissionSet refused, PermissionSet demands, >> > RuntimeMethodHandle >> > rmh, Object assemblyOrString, SecurityAction action, Boolean >> > throwException) >> > at >> > System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack >> > cs, >> > PermissionSet grants, PermissionSet refused, PermissionSet demands, >> > RuntimeMethodHandle rmh, Assembly asm, SecurityAction action) >> > at StoredProcedures.SPInsertTest() >> > >> > "Nicole Calinoiu" wrote: >> > >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> news:B18265E8-0152-4E87-8278-147945E8DDAC@microsoft.com... >> >> <snip> >> >> > Is it possible to create appdomains in the managed stored procedure? >> >> >> >> From what I've seen written about the SQL CLR hosting model, I would >> >> guess >> >> that the designers' intent is probably to prevent any creation of app >> >> domains by user code. However, the official documentation is quite >> >> vague >> >> on >> >> this topic, so you might want to ask about it in the beta newsgroups >> >> at >> >> http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&slcid=us. >> >> >> >> >> >> > As I have explained my problem above, is there any other way to do >> >> > this? >> >> >> >> If you are the author of the target DLLs, the cleanest approach might >> >> be >> >> to >> >> modify the DLLs so that they can read the relevant data from a source >> >> specified by the caller, falling back to the default config file if no >> >> other >> >> source is specified. If this isn't an option, would launching the exe >> >> via >> >> System.Diagnostics.Process.Start offer sufficient control for your >> >> purposes? >> >> >> >> >> >> >> >> > Your help is highly appreciated. >> >> > Thanks in advance, >> >> > >> >> > "Nicole Calinoiu" wrote: >> >> > >> >> >> Even if you could get past this exception, you would block on the >> >> >> next >> >> >> line >> >> >> since the SQL CLR host blocks the necessary call. Might it be >> >> >> possible >> >> >> to >> >> >> alter your target assembly so that the call can be made as a simple >> >> >> method >> >> >> invocation? >> >> >> >> >> >> >> >> >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> >> news:107A2752-4FDE-43B5-86D2-3506052BB057@microsoft.com... >> >> >> > Hi Nicole, >> >> >> > Follwoing is the code that generates this exception >> >> >> > >> >> >> > public static void SPInsertTest() >> >> >> > { >> >> >> > AppDomainSetup ads = new AppDomainSetup(); >> >> >> > ads.ApplicationBase = @"C:\SPTestExe"; >> >> >> > ads.ConfigurationFile = >> >> >> > @"C:\SPTestExe\TestAppExe.exe.config"; >> >> >> > AppDomain ad = AppDomain.CreateDomain("TestApp", null, >> >> >> > ads); >> >> >> > ad.ExecuteAssembly(@"c:\SPTestExe\TestAppExe.exe"); >> >> >> > } >> >> >> > >> >> >> > "Nicole Calinoiu" wrote: >> >> >> > >> >> >> >> What is the code for the version of SPInsertTest that generates >> >> >> >> this >> >> >> >> exception? >> >> >> >> >> >> >> >> >> >> >> >> "Praisy" <Praisy@discussions.microsoft.com> wrote in message >> >> >> >> news:F83105AF-E82B-481B-A231-5E1948545CCF@microsoft.com... >> >> >> >> > Hi! >> >> >> >> > Thanks for the info. While creating the assembly in SQLServer >> >> >> >> > 2005, >> >> >> >> > I >> >> >> >> > had >> >> >> >> > set the PERMISSION_SET to EXTERNAL_ACCESS during which I got >> >> >> >> > the >> >> >> >> > security >> >> >> >> > Exception. Now I changed to UNSAFE and got the >> >> >> >> > TypeLoadException >> >> >> >> > as >> >> >> >> > follows. >> >> >> >> > >> >> >> >> > System.TypeLoadException: The domain manager specified by the >> >> >> >> > host >> >> >> >> > could >> >> >> >> > not >> >> >> >> > be instantiated. >> >> >> >> > at System.AppDomain.nCreateDomain(String friendlyName, >> >> >> >> > AppDomainSetup >> >> >> >> > setup, Evidence providedSecurityInfo, Evidence >> >> >> >> > creatorsSecurityInfo, >> >> >> >> > IntPtr >> >> >> >> > parentSecurityDescriptor) >> >> >> >> > at System.AppDomainManager.CreateDomainHelper(String >> >> >> >> > friendlyName, >> >> >> >> > Evidence securityInfo, AppDomainSetup appDomainInfo) >> >> >> >> > at System.AppDomainManager.CreateDomain(String friendlyName, >> >> >> >> > Evidence >> >> >> >> > securityInfo, AppDomainSetup appDomainInfo) >> >> >> >> > at System.AppDomain.CreateDomain(String friendlyName, >> >> >> >> > Evidence >> >> >> >> > securityInfo, AppDomainSetup info) >> >> >> >> > at StoredProcedures.SPInsertTest() >> >> >> >> > >> >> >> >> > Any idea what can be the reason?? >> >> >> >> > Thanks, >> >> >> >> > >> >> >> >> > >> >> >> >> > "Nicole Calinoiu" wrote: >> >> >> >> > >> >> >> >> >> SQL Server 2005 imposes additional permission restrictions on >> >> >> >> >> managed >> >> >> >> >> code
Don't see what you're looking for? Try a search.
|
|
|