Showing posts with label dll. Show all posts
Showing posts with label dll. Show all posts

Friday, March 9, 2012

'microsoft.sqlserver.batchparser' is malformed or not a pure .NET assembly.

Hi all,

I have a small dll that use the SQL Server 2005 SMO library. SQL Server 2005 has SP 1 installed. When I tried to register the assembly with the followin command, I get the error shown. If I remove all references to SMO, the assembly registered fine.
I really need help on this.

Thanks in advance.

CREATE ASSEMBLY ACDataBridge
FROM
'H:\User\Development\Projects\Applications\ACDataBridge\bin\Debug\Projects.Applications.ACDataBridge.dll'
WITH PERMISSION_SET = UNSAFE

Msg 6544, Level 16, State 1, Line 1
CREATE ASSEMBLY for assembly 'Projects.Applications.ACDataBridge' failed because assembly 'microsoft.sqlserver.batchparser' is malformed or not a pure .NET assembly.
Unverifiable PE Header/native stub.

Hi,

Unfortunately in SqlServer 2005 we do not support loading SMO in SQLCLR. If you want to build your assembly for dual use (i.e. both inside SQLCLR and on the client) you can load SMO via reflection. This works in a rather narrow set of scenarios though, for the next version of SqlServer we are looking at making sure that SMO loads and works inside SQLCLR.

Regards,

Ciprian Gerea, SqlServer SDE

|||

Hi Ciprian,

Thank you so much for your repy. For a minute, I thought this post would never be answere. Your sggestion sounds good, but I have tried loading assebly dynamically in SQLCLR code and it was failing; here is one:

I use Assembly.LoadFrom("test.dll"); to dynamically load a dll in a SQL CLR pocedure method, but I get this error:

System.IO.FileLoadException: LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host.

First method:
I have also tried to activate a managed COM, and it fails:

//Get IDispatch Interface
Type objMethodType = Type.GetTypeFromProgID("CLRServer.CServerObject");
//Create Instance
object objMethod = Activator.CreateInstance(objMethodType);
//Make Array of Arguments
object[] myArguments =
{
strKeySet, strTarget, strMetadata
};
//Invoke Add Method
strReturnParam = (String)objMethodType.InvokeMember(
"Process", BindingFlags.InvokeMethod, null, objMethod, myArguments);

Second method:
I tried to activate an unmanaged COM, which in turn, calls a method in the above managed COM:
The instance of the unmanaged COM was created succesfully, but the method call failed with COMExeption

//Get IDispatch Interface
Type objMethodType = Type.GetTypeFromProgID("CComNativeLink2.CComNativeLink.1");
//Create Instance
object objMethod = Activator.CreateInstance(objMethodType);
//Make Array of Arguments
object[] myArguments =
{
strKeySet, strTarget, strMetadata
};
//Invoke Add Method
strReturnParam = (String)objMethodType.InvokeMember(
"ProcessData", BindingFlags.InvokeMethod, null, objMethod, myArguments);

Any idea?

Can you give a sample of your suggestion?

Thanks in advance

|||

I think that Assembly.LoadFrom fails to access the disk if you are registred as SAFE. The reason is that registering as SAFE only gives you only execution privileges, not file access. You should use Assembly.Load instead. But let me make something clear - this does not mean that you will be able to use SMO inside SQLCLR this way, it's just a way to load SMO only when you're not inside SQLCLR and keep the rest of your application code identical, as much as possible.

As for the COM objects, they are also not supported inside SQLCLR. You can of course use the sp_OACreate & Co. and load the COM stuff into the native space, but this has drawbacks as far as reliability and performance. If the native objects loads a managed assembly it will still be subject to the same restrictions.

Ciprian

|||

Hi Ciprian,

Thank you so much for clarifying that. Unfortunately, I had already tried sp_OACreate and it failed also due to managed COM. I guess my only option left would be extended stored procedure and managed COM. Or is that going to fail also?

|||

I'm afraid it will also fail. There is currently no way you can run SMO inside SQLCLR.

Ciprian

|||Is there another way to script out objects from within SQL Server?

This is very disappointing.

'microsoft.sqlserver.batchparser' is malformed or not a pure .NET assembly.

Hi all,

I have a small dll that use the SQL Server 2005 SMO library. SQL Server 2005 has SP 1 installed. When I tried to register the assembly with the followin command, I get the error shown. If I remove all references to SMO, the assembly registered fine.
I really need help on this.

Thanks in advance.

CREATE ASSEMBLY ACDataBridge
FROM
'H:\User\Development\Projects\Applications\ACDataBridge\bin\Debug\Projects.Applications.ACDataBridge.dll'
WITH PERMISSION_SET = UNSAFE

Msg 6544, Level 16, State 1, Line 1
CREATE ASSEMBLY for assembly 'Projects.Applications.ACDataBridge' failed because assembly 'microsoft.sqlserver.batchparser' is malformed or not a pure .NET assembly.
Unverifiable PE Header/native stub.

Hi,

Unfortunately in SqlServer 2005 we do not support loading SMO in SQLCLR. If you want to build your assembly for dual use (i.e. both inside SQLCLR and on the client) you can load SMO via reflection. This works in a rather narrow set of scenarios though, for the next version of SqlServer we are looking at making sure that SMO loads and works inside SQLCLR.

Regards,

Ciprian Gerea, SqlServer SDE

|||

Hi Ciprian,

Thank you so much for your repy. For a minute, I thought this post would never be answere. Your sggestion sounds good, but I have tried loading assebly dynamically in SQLCLR code and it was failing; here is one:

I use Assembly.LoadFrom("test.dll"); to dynamically load a dll in a SQL CLR pocedure method, but I get this error:

System.IO.FileLoadException: LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host.

First method:
I have also tried to activate a managed COM, and it fails:

//Get IDispatch Interface
Type objMethodType = Type.GetTypeFromProgID("CLRServer.CServerObject");
//Create Instance
object objMethod = Activator.CreateInstance(objMethodType);
//Make Array of Arguments
object[] myArguments =
{
strKeySet, strTarget, strMetadata
};
//Invoke Add Method
strReturnParam = (String)objMethodType.InvokeMember(
"Process", BindingFlags.InvokeMethod, null, objMethod, myArguments);

Second method:
I tried to activate an unmanaged COM, which in turn, calls a method in the above managed COM:
The instance of the unmanaged COM was created succesfully, but the method call failed with COMExeption

//Get IDispatch Interface
Type objMethodType = Type.GetTypeFromProgID("CComNativeLink2.CComNativeLink.1");
//Create Instance
object objMethod = Activator.CreateInstance(objMethodType);
//Make Array of Arguments
object[] myArguments =
{
strKeySet, strTarget, strMetadata
};
//Invoke Add Method
strReturnParam = (String)objMethodType.InvokeMember(
"ProcessData", BindingFlags.InvokeMethod, null, objMethod, myArguments);

Any idea?

Can you give a sample of your suggestion?

Thanks in advance

|||

I think that Assembly.LoadFrom fails to access the disk if you are registred as SAFE. The reason is that registering as SAFE only gives you only execution privileges, not file access. You should use Assembly.Load instead. But let me make something clear - this does not mean that you will be able to use SMO inside SQLCLR this way, it's just a way to load SMO only when you're not inside SQLCLR and keep the rest of your application code identical, as much as possible.

As for the COM objects, they are also not supported inside SQLCLR. You can of course use the sp_OACreate & Co. and load the COM stuff into the native space, but this has drawbacks as far as reliability and performance. If the native objects loads a managed assembly it will still be subject to the same restrictions.

Ciprian

|||

Hi Ciprian,

Thank you so much for clarifying that. Unfortunately, I had already tried sp_OACreate and it failed also due to managed COM. I guess my only option left would be extended stored procedure and managed COM. Or is that going to fail also?

|||

I'm afraid it will also fail. There is currently no way you can run SMO inside SQLCLR.

Ciprian

|||Is there another way to script out objects from within SQL Server?

This is very disappointing.

Wednesday, March 7, 2012

microsoft.exceptionmessagebox.dll

I wanted to use the SQL server SDK samples and i need the assembly microsoft.exceptionmessagebox.dll ; can you, please, tell me where i can find it? is it installed by the SQL server installer with the DataBase engine integration services or something else?

i'm using SQL Server Express Edition. i looked in the directory "C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies" and i didn' find it.

thanks.

it's me,

I have just found what was wrong.

In the samples they used the assembly microsoft.exceptionmessagebox.dll and with sql server express we should use this one

Microsoft.NetEnterpriseServers.Express.ExceptionMessageBox.dll

it can be found in C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\

this is likely the same assembly cause inside they, both, include the ExceptionMessageBox Class.

Microsoft.AnalysisServices.Viewers.DLL Microsoft SQL Server 2005 Datamining Viewer Controls

Hi

I am trying to use Association Viewer Control in

Microsoft.AnalysisServices.Viewers.DLL dll in VS 2005 but sometimes it gives an error.

"Code generatio for property 'ConnecitonManager'" failed. Error was:'Property accesor 'ConnectionManager' on object 'AssosiactionViewer1' threw the following exception:'Object referance not set to instance of an object"


Is there anyone here who use
"Microsoft SQL Server 2005 Datamining Viewer Controls" in SQLServer2005 FeaturePack ?
http://www.microsoft.com/downloads/details.aspx?FamilyID=50b97994-8453-4998-8226-fa42ec403d17&DisplayLang=en

i am using VS2005 Version 8.0.50727.762 (SP.050727-7600)
and SQL Server 2005 SP2

thanks from now.

Cem üney

Thanks for reporting this issue. We are trying to reproduce this problem and will provide an update soon.|||

Thank you very much for your reply.

i hope you can see the same problem.

|||

Cem,

It would be very helpful if you could tell us a little bit more about your problem. Have you found any particular conditions when you hit the error? Are you getting the error when creating the viewer? or after? What are you doing before invoking the viewer? This will save us a lot guessing and we will be able to find the problem and work a solution earlier.

Thanks,

Fernando Godinez, SQL Server Data Mining

|||

ok sir,

i am sending you the pictures that shows my problem. thanks for your interest.

viewer1.jpg

http://img517.imageshack.us/my.php?image=viewer1sz6.jpg

i just open new VBProject.

viewer2.jpg

http://img478.imageshack.us/img478/4223/viewer2jp1.jpg

i add the Microsoft.AnalysisServices.Viewers.dll controls to ToolBox

viewer3.jpg

http://img504.imageshack.us/img504/2976/viewer3qd4.jpg

i just drag and drop the AssociationViewer control to my empty form. When i click properties after 2-3 seconds, it gives me the error at the image.

viewer4.jpg

http://img504.imageshack.us/img504/7746/viewer4ho7.jpg

Connection Manager error and my referances. Maybe i have to some more references but which one?

viewer5.jpg

http://img504.imageshack.us/img504/9749/viewer5if8.jpg

When i close the project and open it again i saw this message Sad

All pictures are here

http://rapidshare.com/files/38900865/viewer.rar.html

|||

Cem,

I was able to reproduce the error and we will work on it. In the meantime here is what you need to do to get you application running:

1. Create a form with a Panel on it.

2. From the code part you will have to create a new AssociatonViewer

3. Set the ConnectionString property for you association viewer manually

4. Set the mining model name that you want to view

5. Add the viewer to the panel controls collection

6. Call the LoadViewerData method from the viewer (context parameter can be null).

* Note: You connection string must have the form "Provider=MSOLAP.3;Data Source= your server name;Initial Catalog=your catalog". Where you must provide your server name and your catalog name.

You can see an implementation on the use of the controls in http://www.sqlserverdatamining.com/dmcommunity/_downloads/1361.aspx

All the code in that sample is in C# but I'm sure you can get the grasp without much trouble.

Hope this helped,

Fernando

|||

ok fernando,

i know the example before, and i adapted it to VB.

control does not give error when its created at runtime.

thanks for your interest again.

Cem üney