Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 assembly does not allow partially trusted callers

Author  Topic 

beyonder422
Posting Yak Master

124 Posts

Posted - 2009-04-21 : 17:37:43
Farily new to 2005 CLR - I am trying to send an xml message via MSMQ from a stored procedure.

I am passing an XmlDocument object to a Message and am receiving errors.

First I resolved this: [url]http://kbalertz.com/913668/Error-message-common-language-runtime-object-Server-dynamically-generated-serialization.aspx[/url], only to start seeing this [url]http://www.kodyaz.com/blogs/software_development_blog/archive/2006/10/15/455.aspx[/url] and can't seem to get past the "assembly does not allow ..." issue.

This method works via web page, but this has to be a SQL Server 2005 security issue, becuase that is the only place it is failing.

I have been looking everywhere and have tried at least 20 different iterations.

I created (sgen) the serialized version, my assembly is strong named, the XmlSerializer is strong named, the assembly property AllowPartiallyTrustedCallers is set.

My db is set trustworthy on

assemblies Permission set: Safe - primary and XmlSerializer

What else can I do, how else can I gather more info to help me troubleshoot?


---------------------
I do not define what is obvious...

beyonder422
Posting Yak Master

124 Posts

Posted - 2009-04-21 : 17:39:13
Sample code trying to send xml message to MSMQ from stored procedure:

public static void Send(SqlString queue, SqlString msg)
{
XmlDocument _xmlDoc;
XmlNode _xmlNode;
XmlElement _xmlElement1;
XmlElement _xmlElement2;
XmlText _xmlText;

_xmlDoc = new XmlDocument();

_xmlNode = _xmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
_xmlDoc.AppendChild(_xmlNode);

_xmlElement1 = _xmlDoc.CreateElement("", "ROOT", "");
_xmlText = _xmlDoc.CreateTextNode("");
_xmlElement1.AppendChild(_xmlText);
_xmlDoc.AppendChild(_xmlElement1);

_xmlElement2 = _xmlDoc.CreateElement("", "PLCID", "");
_xmlText = _xmlDoc.CreateTextNode("1");
_xmlElement2.AppendChild(_xmlText);
_xmlDoc.ChildNodes.Item(1).AppendChild(_xmlElement2);

using (MessageQueue msgQueue = new MessageQueue(queue.ToString(), QueueAccessMode.Send))
{
//// version1
//msgQueue.Formatter = new XmlMessageFormatter(new System.Type[] { typeof(string) });
msgQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
msgQueue.Send(msg.Value);
//msgQueue.Send(_xmlDoc);

//version2
//XmlNode node = _xmlDoc;
//XmlSerializer XS = new XmlSerializer(typeof(XmlNode));
//MemoryStream MS = new MemoryStream();

//XS.Serialize(MS, node);
//string str = System.Text.Encoding.ASCII.GetString(MS.GetBuffer());
//string label = string.Format("Sent at {0}", DateTime.Now);
//msgQueue.Send(str, label);
}
}

---------------------
I do not define what is obvious...
Go to Top of Page

beyonder422
Posting Yak Master

124 Posts

Posted - 2009-04-21 : 17:42:12
Sample database code:

alter database test set trustworthy on

create assembly Messaging
authorization dbo
from 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Messaging.dll'
with permission_set = unsafe
go

-- version 2
create assembly [nsSqlMsmq] from 'C:\temp\nsSqlMsmq.dll'
create assembly [nsSqlMsmq.XmlSerializers.dll] from 'C:\temp\nsSqlMsmq.XmlSerializers.dll'

-- Create procedures
create PROCEDURE uspMSMQSend
@queue nvarchar(200),
@msg nvarchar(MAX)
AS EXTERNAL NAME nsSqlMsmq.[nsSqlMsmq.clsSqlMsmq].Send
GO

--EXEC uspMSMQSend 'server-name\private$\queuename', '<value>1</value>'

---------------------
I do not define what is obvious...
Go to Top of Page

beyonder422
Posting Yak Master

124 Posts

Posted - 2009-04-27 : 09:09:45
No input at all?

---------------------
I do not define what is obvious...
Go to Top of Page
   

- Advertisement -