Showing posts with label assembly. Show all posts
Showing posts with label assembly. Show all posts

Thursday, March 29, 2012

Error: CREATE ASSEMBLY for assembly

I am trying to deploy a Database Project with Visual Studio 2005 and SQL Server 2005 Standard.

I import “System.IO” and have therefore set the permission levels to EXTERNAL_ACCESS.

I am receiving the same error message that many folks have received.

CREATE ASSEMBLY for assembly 'Images' failed because assembly 'Images' is not authorized for PERMISSION_SET = EXTERNAL_ACCESS.

The assembly is authorized when either of the following is true: the database owner (DBO) has EXTERNAL ACCESS ASSEMBLY permission and the database has the TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with EXTERNAL ACCESS ASSEMBLY permission. If you have restored or attached this database, make sure the database owner is mapped to the correct login on this server. If not, use sp_changedbowner to fix the problem. Images.

My CLR access is “on”

I have tried

1) From master run: GRANT EXTERNAL ACCESS ASSEMBLY to [Builtin\Administrators].

2) From master run: GRANT EXTERNAL ACCESS ASSEMBLY to “My Windows Authentication ID”.

3) Run ALTER DATABASE MYDATABASE SET TRUSTWORTHY ON

4) In Visual Studio .NET 2005 Set the permission levels to ‘external’

5) Tried Builtin\Administrators and my SQL Server Windows Authenticated Login ID for the ASSEMBLY OWNER.

I can compile BUT NOT DEPLOY

Any help would be greatly appreciated.

Regards Steve

Who is the owner of the database ?

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Hi Thanks for the reply.

I am running with Windows Authentication at the present moment , under the ID Administrator1 (running under windows Vista.(still would like to get reporting services to run Smile ) . I did read the article on "Opening up the Administrator ID in Vista and installing SQL Server 2005 under that ID."

Re my current problem....

I managed to get it to deploy. I assigned Administrator1 as an "owner" of the database and gave the ID security administrator rights. I did the same with Builtin/Administrator.

I found something very interesting. I am able to deploy CLR stored precedures from the Visual Studio environment but not CLR functions. (EXTERNAL ACCESS) In order to deply functions I must compile the Dll and create SQL to CREATE the ASSEMBLYfrom within the SQL Server Environment. Any ideas why.?

Once again thanks for the help? Very much appreciated.

Steve

|||

OK Folks this took me about 3 hours to do BUT I have resolved the problem and it WORKS!!!

BTW I am using SQL Server 2005 Standard and Visual Studio.NET Enterprise

First create a Strong key as described in“The secret of strong naming”

DO NOT DODELAY SIGNING !!!!!!

http://www.ondotnet.com/pub/a/dotnet/2003/04/28/strongnaming.html

Sn – k MyKeyFile.snk

FIND OUT WHERE THE SNK FILE WAS COMPILED.

Go into VS2005 .NET and under project / properties in the signing page click the Sign the Assembly check box and browse to find MyKeyFile.snk

The database page

Mark the assembly for external access and leave the owner blank

Now we must go to the article

http://sqljunkies.com/WebLog/ktegels/archive/2006/08/14/safetydancelite.aspx

The text below comes from this article....Smile

A kinder, lighter Safety Dance for the SQLCLR

A few months ago, I published a step-by-step procedure for using certificate to sign an assembly so an external access or unsafe assembly could be run without having to set the hosting database to trustworthy. The major problem with that process was its weight: a lot of steps and some still requirements in terms of certificate management. Turns out that yes, there is an easier way to make it work.

Part one -- preparing the master database

1. As needed, start a series of queries against the MASTER database.

2. Create the target database (meaning execute a CREATE DATABASE query).

3. Code and compile the assembly you want to deploy. Make sure you sign the assembly with a strong name key file. This can be done with a PFX file generated by Visual Studio.

4. Create an asymmetric key from from the compiled assembly using a statement like this: create asymmetric key <key_name> from executable file = '<path_to_dll_file>'

USE Master

GO

create asymmetric key imageskeyFile from executable file = 'C:\YEAR 2007\Images\Images\bin\Debug\Images.dll'

5. Create a login based on that asymmetric key using a statement like this: create login <login_name> from asymmetric key <key_name>

Use Master

Go

create login ImageMaker from asymmetric key imageskeyFile

6. Grant that login the right to create either or both an unsafe or external access assembly (as needed) using: grant unsafe assembly to <login_name>

Use Master

Go

grant EXTERNAL ACCESS assembly to ImageMaker

Part two -- preparing the hosting database

1. As needed, start a series of queries against the desired user database.

2. Create a user in that database mapped to the login created in part, step 5. (e.g. create user <db_user> from login <login_name>)

3. Give that user the right to catalog an assembly, e.g.: grant create assembly to <db_user>

4. Catalog the desired assembly using the now trusted asymmetric key with a statement like: create assembly <assembly_name> authorization <db_user> from '<path_to_dll_file>' with permission_set = unsafe or external access as shown below

SET QUOTED_IDENTIFIER OFF

USE YEAR2007

GO

CREATE ASSEMBLY Images

AUTHORIZATION ImageMaker

FROM "C:\YEAR 2007\Images\Images\bin\Debug\Images.dll"

WITH PERMISSION_SET = EXTERNAL_ACCESS

GO

Error: Could not connect to database

The following error is encountered while trying to Host the site from IIS ..
" The Assembly Version ([ASSEMBLY VERSION]) does not match the Database Version ([DATABASE VERSION]).
"Error: Could not connect to the database specified in the connection string for SqlDataProvider. "

We have 2 different machines, over which we have 2 different SQL Server.
In Web.Config, if we give server=server1 it works well and there is no problem at all...
if we give server=server2, and executehttp://localhost/application, the above mentioned error occurs..

and yes the application is hosted on 3rd machine......

Can anyone throw some light on this regard.
Its urgent.

You're using DotNetNuke, right? Try this search on the Forums to see other threads on this topic:
http://forums.asp.net/search/SearchResults.aspx?q=ASSEMBLY+VERSION+match+DATABASE+VERSION&o=Relevance

Sunday, February 19, 2012

Error while registering assembly that uses ActiveX wrapper stdole

> 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

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.|||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
|||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

Friday, February 17, 2012

Error while loading custom assembly in Designer

I've created a custom assembly using C# that provides utility functions for
reporting services. I'm getting a the following compile time errors.
1. Error while loading code module: 'accentopto.report.utilities,
Version=1.0.1885.19928, Culture=en-US, PublicKeyToken=null'. Details: File or
assembly name accentopto.reporting.utilities, or one of its dependancies, was
not found.
2. Error in class instance declaration for class Utilities: [BC30002] Type
'Utilities' is not defined.
I've verified the version metadata using ildasm.
Here are the CodeModules and Classes elements from the .rdl file.
<CodeModules>
<CodeModule>accentopto.report.utilities, Version=1.0.1885.19928,
Culture=en-US, PublicKeyToken=null</CodeModule>
</CodeModules>
<Classes>
<Class>
<ClassName>Utilities</ClassName>
<InstanceName>Utilities</InstanceName>
</Class>
</Classes>
Here is the CodeGroup element in the rspreviewpolicy.config file for the
Designer
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="Execution"
Name="Accent_Reporting_Utilities"
Description="Code group for Accent data processing extensions">
<IMembershipCondition class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\80\Tools\Report
Designer\accentopto.report.utilities.dll"/>
</CodeGroup>
I've verified that the assembly is in the Report Designer directory.
Here's the code snippet from the Utilities class.
--
using System;
using System.Globalization;
namespace com.accentopto.bizlogic.reporting.rs_shared
{
/// <summary>
/// Shared reporting utilities
/// </summary>
public class Utilities
{
private CultureInfo culture;
private Calendar calendar;
public Utilities()
{
this.culture = new CultureInfo("en-US", false);
this.calendar = culture.Calendar;
}
protected DateTime WeekEndDate(string inDate)
{
DateTime dateOut, dateIn;
string day;
dateIn = Convert.ToDateTime(inDate, culture);
day = dateIn.DayOfWeek.ToString();
switch(day)
{
case "Sunday":
dateOut = dateIn.AddDays(6);
break;
case"Monday":
dateOut = dateIn.AddDays(5);
break;
case "Tuesday":
dateOut = dateIn.AddDays(4);
break;
case "Wednesday":
dateOut = dateIn.AddDays(3);
break;
case "Thursday":
dateOut = dateIn.AddDays(2);
break;
case "Friday":
dateOut = dateIn.AddDays(1);
break;
default:
dateOut = dateIn;
break;
}
return dateOut;
}
/*
* Entry point for testing only
*
public static void Main(string []args)
{
string printDate;
Utilities util;
util = new Utilities();
printDate = util.WeekEndDate(args[0]).ToString();
Console.WriteLine(printDate);
}
*/
}
}
The only thing that I can think of is that my refs to System.Globalization
aren't available.
Thanks for any help.
--
Chris Mackey
Sr. Software Developer
Accent Optical TechnologiesSorry about the redundant entry. The server gave me an error on the first
submission so I thought that it didn't go through. In fact the error message
said that it didn't. Please remove this entry.
"Chris Mackey" wrote:
> I've created a custom assembly using C# that provides utility functions for
> reporting services. I'm getting a the following compile time errors.
> 1. Error while loading code module: 'accentopto.report.utilities,
> Version=1.0.1885.19928, Culture=en-US, PublicKeyToken=null'. Details: File or
> assembly name accentopto.reporting.utilities, or one of its dependancies, was
> not found.
> 2. Error in class instance declaration for class Utilities: [BC30002] Type
> 'Utilities' is not defined.
> I've verified the version metadata using ildasm.
> Here are the CodeModules and Classes elements from the .rdl file.
> <CodeModules>
> <CodeModule>accentopto.report.utilities, Version=1.0.1885.19928,
> Culture=en-US, PublicKeyToken=null</CodeModule>
> </CodeModules>
> <Classes>
> <Class>
> <ClassName>Utilities</ClassName>
> <InstanceName>Utilities</InstanceName>
> </Class>
> </Classes>
> Here is the CodeGroup element in the rspreviewpolicy.config file for the
> Designer
> <CodeGroup class="UnionCodeGroup"
> version="1"
> PermissionSetName="Execution"
> Name="Accent_Reporting_Utilities"
> Description="Code group for Accent data processing extensions">
> <IMembershipCondition class="UrlMembershipCondition"
> version="1"
> Url="C:\Program Files\Microsoft SQL Server\80\Tools\Report
> Designer\accentopto.report.utilities.dll"/>
> </CodeGroup>
> I've verified that the assembly is in the Report Designer directory.
> Here's the code snippet from the Utilities class.
> --
> using System;
> using System.Globalization;
> namespace com.accentopto.bizlogic.reporting.rs_shared
> {
> /// <summary>
> /// Shared reporting utilities
> /// </summary>
> public class Utilities
> {
> private CultureInfo culture;
> private Calendar calendar;
> public Utilities()
> {
> this.culture = new CultureInfo("en-US", false);
> this.calendar = culture.Calendar;
> }
> protected DateTime WeekEndDate(string inDate)
> {
> DateTime dateOut, dateIn;
> string day;
> dateIn = Convert.ToDateTime(inDate, culture);
> day = dateIn.DayOfWeek.ToString();
> switch(day)
> {
> case "Sunday":
> dateOut = dateIn.AddDays(6);
> break;
> case"Monday":
> dateOut = dateIn.AddDays(5);
> break;
> case "Tuesday":
> dateOut = dateIn.AddDays(4);
> break;
> case "Wednesday":
> dateOut = dateIn.AddDays(3);
> break;
> case "Thursday":
> dateOut = dateIn.AddDays(2);
> break;
> case "Friday":
> dateOut = dateIn.AddDays(1);
> break;
> default:
> dateOut = dateIn;
> break;
> }
> return dateOut;
> }
> /*
> * Entry point for testing only
> *
> public static void Main(string []args)
> {
> string printDate;
> Utilities util;
> util = new Utilities();
> printDate = util.WeekEndDate(args[0]).ToString();
> Console.WriteLine(printDate);
> }
> */
> }
> }
> The only thing that I can think of is that my refs to System.Globalization
> aren't available.
> Thanks for any help.
> --
> Chris Mackey
> Sr. Software Developer
> Accent Optical Technologies

Error while loading code module

I have created a custom assembly and referenced it. The class can be
instantiated, so I have specified the class and instance name.
So, when I build the solution, the compiler returns these errors:
Error while loading code module: â'XXX, Version=Y.Y.YYYY.YYYYY
Culture=neutral, PublicKeyToken=nullâ'. Details: File or assembly name XXX, or
one of its dependencies, was not found.
Should there be a directory that this assembly be placed? As a test, I
placed the .dll in the GAC and experieced the same error.
Any help would be appreciated.
Thanks - JMLYes, you must place dll file in
\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\bin
directory
Regards
"AgentSmith" <AgentSmith@.discussions.microsoft.com> escribió en el mensaje
news:754CB514-27F9-40F3-82EE-6D46D143DB05@.microsoft.com...
> I have created a custom assembly and referenced it. The class can be
> instantiated, so I have specified the class and instance name.
> So, when I build the solution, the compiler returns these errors:
> Error while loading code module: 'XXX, Version=Y.Y.YYYY.YYYYY
> Culture=neutral, PublicKeyToken=null'. Details: File or assembly name XXX,
or
> one of its dependencies, was not found.
> Should there be a directory that this assembly be placed? As a test, I
> placed the .dll in the GAC and experieced the same error.
> Any help would be appreciated.
> Thanks - JML
>|||What if the report server is not on your machine? Should I just create the
directory?
"plmartinez" wrote:
> Yes, you must place dll file in
> \Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\bin
> directory
> Regards
> "AgentSmith" <AgentSmith@.discussions.microsoft.com> escribió en el mensaje
> news:754CB514-27F9-40F3-82EE-6D46D143DB05@.microsoft.com...
> > I have created a custom assembly and referenced it. The class can be
> > instantiated, so I have specified the class and instance name.
> >
> > So, when I build the solution, the compiler returns these errors:
> >
> > Error while loading code module: 'XXX, Version=Y.Y.YYYY.YYYYY
> > Culture=neutral, PublicKeyToken=null'. Details: File or assembly name XXX,
> or
> > one of its dependencies, was not found.
> >
> > Should there be a directory that this assembly be placed? As a test, I
> > placed the .dll in the GAC and experieced the same error.
> >
> > Any help would be appreciated.
> >
> > Thanks - JML
> >
>
>

Wednesday, February 15, 2012

Error while deploying CLR Assembly.

Hi,
I am using Whidbey and Yukon. I am creating a CLR SP in whidbey and trying
to deploy. I am getting the following error,
Error: Failed to initialize the .NET Framework: 0x80004005(Unspecified
error). You need to restart server to access .NET Framework functionality.
Any one any ideas as whatz going wrong?
Sameer D.As both are in beta, there are dozens of reasons you could be having problem
s.
1. The builds of Yukon and Whidbey are incompatible
2. The version of the .NET Framework installed is incompatible with Yukon
3. You have a bad install (possible with beta builds, more possible with CTP
builds)
Without understanding more about what you have installed, I can only venture
a wild guess about the reason it is blowing up.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"Sameer Dehalvi" wrote:

> Hi,
> I am using Whidbey and Yukon. I am creating a CLR SP in whidbey and trying
> to deploy. I am getting the following error,
> Error: Failed to initialize the .NET Framework: 0x80004005(Unspecified
> error). You need to restart server to access .NET Framework functionality.
> Any one any ideas as whatz going wrong?
> Sameer D.|||Please move this into the 2005 groups:
http://www.aspfaq.com/sql2005/show.asp?id=1
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Sameer Dehalvi" <Sameer Dehalvi@.discussions.microsoft.com> wrote in message
news:C108E25F-A4CE-4532-86BB-A05DA35FD837@.microsoft.com...
> Hi,
> I am using Whidbey and Yukon. I am creating a CLR SP in whidbey and trying
> to deploy. I am getting the following error,
> Error: Failed to initialize the .NET Framework: 0x80004005(Unspecified
> error). You need to restart server to access .NET Framework functionality.
> Any one any ideas as whatz going wrong?
> Sameer D.|||Gregory,
I have a VPC with Whidbey and have installed Yukon on host machine. There is
no way that there may be any compatibility issue, as I was able to build and
deploy the CLR Stored Procs from Whidbey. I tried restarting the host and ma
y
that has caused problem. I tried restarting the Yukon, tried installing
framework 2.0, tried to execute CLR SPs in yukon no luck. However the simple
select statements (T-SQL) execute without any probs. If you have any ideas
suggestions are wel come.
-Sameer.
"Cowboy (Gregory A. Beamer) - MVP" wrote:
> As both are in beta, there are dozens of reasons you could be having probl
ems.
> 1. The builds of Yukon and Whidbey are incompatible
> 2. The version of the .NET Framework installed is incompatible with Yukon
> 3. You have a bad install (possible with beta builds, more possible with C
TP
> builds)
> Without understanding more about what you have installed, I can only ventu
re
> a wild guess about the reason it is blowing up.
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> ***************************
> Think Outside the Box!
> ***************************
> "Sameer Dehalvi" wrote:
>

Error while creating assembly

I am trying to create an assembly on a sql server 2005 machine but it gives me following error:

Msg 33009, Level 16, State 2, Line 2
The database owner SID recorded in the master database differs from the database owner SID recorded in database 'XYZ'. You should correct this situation by resetting the owner of database 'XYZ' using the ALTER AUTHORIZATION statement.

I tried using the alter authorization statement to change the owner.
It did not work.

I am able to create same assembly on another test database but can not create it on this database.

Is this because of orphan logins?

Thanks for the help.

Harshal.Hi

Was this db attached from another instance or upgraded from 2k?

I have had this problem - changing the owner is simple. What do you mean by it didn't work? It should be pretty easy e.g.

USE Mydb
GO

EXEC dbo.sp_changedbowner @.loginame = N'sa', @.map = false
GO|||More info:
http://support.microsoft.com/kb/918040|||Thanks for the reply.
Yes this database was restored from a backup taken from another machine. I fixed the orphaned user and changed the db owner to other user. but still the error persists. though i did not change sa owner.
will try fixin the SA login.


Hi

Was this db attached from another instance or upgraded from 2k?

I have had this problem - changing the owner is simple. What do you mean by it didn't work? It should be pretty easy e.g.

USE Mydb
GO

EXEC dbo.sp_changedbowner @.loginame = N'sa', @.map = false
GO|||Thanks a lot pootle flump.
It worked.