locked
Error while registering assembly that uses ActiveX wrapper stdole RRS feed

  • Question

  •                > Hi,
    >
    > I wrote a dummy Stored Procedure in C#, registered it as assembly,
    > called the SP and everthing was fine (VS2005 C# Express)
    > Then I implemeted functionality into the dummy SP that requires a
    > third party ActiveX. It is integrated in my project by the reference
    > to "stdole". After compiling, I got three DLL:
    >
    > a.dll - with the dummy SP (compiled with strong name)
    > b.dll - the third party OCX
    > stdole.dll - system
    >
    > Now, I have problems registering that stuff. a requires b. b requires
    > c. and c registration is not possible due to that error:
    >
    >
    > Create failed for SqlAssembly 'stdole'.  (Microsoft.SqlServer.Smo)
    > ------------------------------
    > ADDITIONAL INFORMATION:
    >
    > An exception occurred while executing a Transact-SQL statement or
    > batch. (Microsoft.SqlServer.ConnectionInfo)
    >
    > ------------------------------
    >
    > CREATE ASSEMBLY failed because method 'Next' on type
    > 'stdole.IEnumVARIANT'  in safe assembly 'stdole' has invalid attribute
    > 0x1003.
    > Warning: The Microsoft .Net frameworks assembly 'stdole,
    > version=7.0.3300.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.'
    > you are registering is not fully tested in SQL Server hosted environment.
    > Warning: Assembly "stdole" was built using version v1.0.3705 of the
    > .NET Framework. SQL Server currently uses version v2.0.50727.
    > (Microsoft SQL Server, Error: 6215)
    >
    > What can I do to register my a assembly for SQL Server 2005? Wrong
    > compiler setting? How can I make the systems stdole.dll known as an
    > assembly in SQL Server 2005?
    >
    > Thanks for help + regards,
    >
    > Christian
    Tuesday, November 29, 2005 6:44 AM

Answers

  • The problem you have is that you need to create the stdole assembly with a permision set of (I believe) UNSAFE. In order to do that you need to set some additional security details on the database, and there are a couple of ways to do that. The easiest is probably to:
    1. Grant the login of the database owner the UNSAFE ASSMBLY permission.
    2. Mark the database as trustworthy

    Now you should be able to create the assembly with unsafe.

    Niels
    Tuesday, November 29, 2005 1:16 PM

All replies

  • Safe

    Select this option to use this permission set for the assembly reference. If this option is selected, the assembly is allowed only internal computation and local data access. Code executed by an assembly with this option cannot access external system resources such as files, the network, environment variables, or the registry.

    Security Note   This option is the recommended permission setting for assemblies that perform computation and data management tasks without accessing resources outside Analysis Services. This option represents the most restrictive permission set.

    External access

    Select this option to use this permission set for the assembly reference. If this option is selected, the assembly is allowed only internal computation and local data access. Code executed by an assembly with this permission set has the ability to access external system resources such as files, networks, environmental variables, and the registry.

    Security Note   This option is recommended for assemblies that access resources outside Analysis Services. Assemblies using this option, by default, execute using the security credentials of the service account. It is possible for code within this assembly to explicitly impersonate the caller’s Microsoft Windows Authentication security context. Because the default is to execute as the service account, permission to execute assemblies with this option should only be given to roles trusted to run as the service account. This option represents a less restrictive permission set than Safe, but more restrictive than Unrestricted.

    Unrestricted

    Select this option to use this permission set for the assembly reference. If this option is selected, the assembly has unrestricted access to resources, both inside and outside. Code executing from within an assembly with this option can call unmanaged code.

    Security Note   This option is not recommended unless the assembly requires unrestricted access. From a security perspective, this option is identical to External access. However, assemblies using the External access option provide various reliability and robustness protections that are not included in assemblies using this option. Specifying this option allows the code in the assembly to perform illegal operations against the process space and hence can potentially compromise the robustness and scalability of Analysis Services. This option represents the least restrictive permission set, and should be used with caution.


    I got this from msdn2

    Have you tried registering the assembly with one of the above switches?

    It also looks as though the stdole you are using is out of date, perhaps from a previous install.
    Tuesday, November 29, 2005 8:54 AM
  • Hi Simon,

    thanks for your answer. Yes, I tried all that stuff, but it doesn't work. I even generated a strong name for my assembly. No effect.
    I saw that message concerning the version info of stdole, but the strange thing is that VS C# 2005 Express Edition copied that version in my target build folder automatically. So, I assume, it's the correct stdole version ... if not: do you have an idea how I get the correct version?

    Thanks + regards,

    Christian


    Tuesday, November 29, 2005 9:54 AM
  • The problem you have is that you need to create the stdole assembly with a permision set of (I believe) UNSAFE. In order to do that you need to set some additional security details on the database, and there are a couple of ways to do that. The easiest is probably to:
    1. Grant the login of the database owner the UNSAFE ASSMBLY permission.
    2. Mark the database as trustworthy

    Now you should be able to create the assembly with unsafe.

    Niels
    Tuesday, November 29, 2005 1:16 PM
  • Hi,

     

       You need to set SAFE code in two places. First, right click on the properties of your SQLproject and select SAFE code. Second, properties>Build> tick off "Allow unsafe code".

     

    Pablo

    Wednesday, December 15, 2010 11:33 AM