Showing posts with label managed. Show all posts
Showing posts with label managed. Show all posts

Saturday, February 25, 2012

Assembly.Load can't load my custom assembly from the GAC.

Hi there.

I have an assembly, call it A1, that I've deployed to a SQL Server 2005 database. I can use the managed stored procedures from A1 in SQL Server no problem.

In A1 there is a bit of code which uses the Assembly.Load() method, so load another assembly and use instances of class found in that external assembly. However, when I run the managed stored proc in A1 that uses Assembly.Load() I get the error:

Could not load file or assembly 'A1, Version=1.0.0.0, Culture=neutral,PublicKeyToken='?' or one of its dependencies. The system cannot find the file specified.

(note: for security I've changed some of the above line).

So I changed the Assembly.Load() to use

System.Data,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089

I re-built the project, re-deployed it and ran the code in SQL Server - it worked. I could create an instance of a System.Data.DataSet for example. So why can't I load my own custom assembly? My assembly does have a strong name and it's installed in the GAC. I wrote a console app to try and Assembly.Load() my custom assembly and that worked fine (it was also running on the same server as the SQL Server).

So it's defiantely the SQL Server that can't 'see' my customer assembly. What do I need to do this assembly so that SQL Server will allow me to Assembly.Load it, just as it can with System.Data?

Thanks
Jas.

Hi Jas,

In order you load your assembly using Assembly.Load, the assembly already has to be loaded into your database using CREATE ASSEMBLY. SqlClr will only load assemblies directly from the gac that are on the list of supported framework assemblies available here: http://msdn2.microsoft.com/en-us/library/ms403279.aspx. All the assemblies on that list (including System.Data) can be accessed by any assembly in your database, but all other assemblies must be loaded using CREATE ASSEMBLY first.

Steven

ASPState Select Permission Denied

I've been scouring the 'Net and I'm surprised to not find any info on this. Apparently I've screwed up something that nobody else has managed to screw up.

Using Win03EE and SQL2005.

I created the ASPState database using "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Aspnet_regsql.exe" using "-sstype p" to put the data in ASPState instead of tempdb.

During the creation I used an admin SQL login (let's call it "MyAdmin") that has full admin permissions. (MyAdmin is a SQL login, not a domain account.) I then created an "ASPState" SQL login (not domain) and gave it full permissions within the ASPState database.

I should probably note that the Win03EE server is also a domain controller even though the SQL logins I'm using are non-domain. This is because, currently, the development workstations are not part of the server's domain. Since the entire environment is strictly for research and development, optimum security is not the first concern at this point.

When I run the ASP.NET 2.0 web application with the connection string set to use the MyAdmin account, everything works fine. I can even poke around in ASPState with SSMS and see the session entries being inserted in the tables.

When I run the application with the connection string set to use the "ASPState" login, I get "SELECT permission denied on object 'sysobjects', database 'mssqlsystemresource', schema 'sys'".

If I give ASPState sysadmin priviledges, it works. Of course, I don't want to give ASPState sysadmin priviledges.

I have seen non-ASPState issues posted on the 'Net involving permission denied and mssqlsystemresource. From those I've come to understand that this likely has to do with the changes made to SQL2005 that are probably not anticipated by the current version of aspnet_reqsql.

So... can anyone help me save what's left of my hair from being pulled out any further? I've been clicking various permission settings on and off all day long with no results. The lack of correlation between mssqlsystemresource and what permission setting is needed where is pretty frustrating.

In addition to the solution to this problem, I'd really appreciate any info anyone has on a great place to go read about security setting adjustment considerations in light of the changes made in SQL2005. In particular, what changes from SQL2000 to SQL2005 impact the operation of existing SQL2000 code and what an admin should know about adjusting security settings.

Thanks!

I was about to explain the reason with a resolution by referring a KBA, but found this interesting page http://idunno.org/dotNet/sessionState.aspx on web in this regard.

Sunday, February 12, 2012

ASP.NET 2.0 with goDaddy

I was wondering if anyone successfully managed to connect to theasp.net 2.0 features (specifically authentication) with goDaddy. Theyallow you to set up the schema for 2.0 in the SQL server, but I haveyet to manage to actually CONNECT to the SQL server using VS.NET 2005.Anyone have any suggestions? Experiences?

Hello, Brother

My name is Jose Luis, I want to connect MS SQL of GoDaddy.com with Visual Studio 2005, i have the connection that Godaddy give me, it hasn't any mistake, but when i use the GridView lanch a mistake.

Code Connection:

<?

xmlversion="1.0"?>

<!--

Note: As an alternative to hand editing this file you can use the

web admin tool to configure settings for your application. Use

the Website->Asp.Net Configuration option in Visual Studio.

A full list of settings and comments can be found in

machine.config.comments usually located in

\Windows\Microsoft.Net\Framework\v2.x\Config

-->

<

configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<

appSettings/>

<

connectionStrings>

<

addname="Personal"connectionString="

Server=whsql-v12.prod.mesa1.secureserver.net;

Database=DB_104431;

User ID=adminzs;

Password=Admin123;

Trusted_Connection=False

"providerName="System.Data.SqlClient" />

<

removename="LocalSqlServer"/>

<

addname="LocalSqlServer"connectionString="

Server=whsql-v12.prod.mesa1.secureserver.net;

Database=DB_104431;

User ID=adminzs;

Password=Admin123;

Trusted_Connection=False

"providerName="System.Data.SqlClient" />

</

connectionStrings>

<

system.web>

<!--

Set compilation debug="true" to insert debugging

symbols into the compiled page. Because this

affects performance, set this value to true only

during development.

Visual Basic options:

Set strict="true" to disallow all data type conversions

where data loss can occur.

Set explicit="true" to force declaration of all variables.

-->

<

compilationdebug="true"strict="false"explicit="true">

<

assemblies>

<

addassembly="ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>

<

pages>

<

namespaces>

<

clear/>

<

addnamespace="System"/>

<

addnamespace="System.Collections"/>

<

addnamespace="System.Collections.Specialized"/>

<

addnamespace="System.Configuration"/>

<

addnamespace="System.Text"/>

<

addnamespace="System.Text.RegularExpressions"/>

<

addnamespace="System.Web"/>

<

addnamespace="System.Web.Caching"/>

<

addnamespace="System.Web.SessionState"/>

<

addnamespace="System.Web.Security"/>

<

addnamespace="System.Web.Profile"/>

<

addnamespace="System.Web.UI"/>

<

addnamespace="System.Web.UI.WebControls"/>

<

addnamespace="System.Web.UI.WebControls.WebParts"/>

<

addnamespace="System.Web.UI.HtmlControls"/>

</

namespaces>

</

pages>

<!--

The <authentication> section enables configuration

of the security authentication mode used by

ASP.NET to identify an incoming user.

-->

<

authenticationmode="Windows"/>

<!--

The <customErrors> section enables configuration

of what to do if/when an unhandled error occurs

during the execution of a request. Specifically,

it enables developers to configure html error pages

to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

<error statusCode="403" redirect="NoAccess.htm" />

<error statusCode="404" redirect="FileNotFound.htm" />

</customErrors>

-->

</

system.web>

</

configuration>

and the Error is:

Database schema could not be retrieved for this conection....

Reply inmaquina007@.gmail.com

Thanks