Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The notification could not be formatted.

0 views
Skip to first unread message

Joe

unread,
Sep 27, 2005, 7:14:04 AM9/27/05
to
I've developed a custom formatter component to transform complex XML
documents, and get the following error when trying to use it:

<NotificationServicesEvent>
<Description>
The notification could not be formatted.
</Description>
<Context>
<EventParameters>
<InstanceName>NHSDInstance</InstanceName>
<ApplicationName>NHSD</ApplicationName>
<Distributor Id>1</Distributor Id>
<Distributor Name>NHSDDist1</Distributor Name>
<Distributor Work Item Id>4</Distributor Work Item Id>
<NotificationClassName>NHSDValidationNotifications</NotificationClassName>
<Notification Id>7</Notification Id>
</EventParameters>
</Context>
<Description>
Request for the permission of type
System.Security.Permissions.StrongNameIdentityPermission, mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
</Description>
<Instance>NHSDInstance</Instance>
<ApplicationName>NHSD</ApplicationName>
<Component>Distributor</Component>
<ComponentDetails>
DistributorName: NHSDDist1
</ComponentDetails>
<Thread>284</Thread>
</NotificationServicesEvent>

After extensive googling, I'm still pretty much none the wiser.

The dll was created using v1.0.3705, which, I'm guessing is at the root of
the problem.

I've also included the dll code, as I think this possibly has a bearing too.

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using Microsoft.SqlServer.NotificationServices;
using Microsoft.SqlServer.NotificationServices.Common;

namespace ContentFormatter
{
public class ComplexTransformation : IContentFormatter
{
private bool initialised;

private string xsltBaseDirectoryPath;
private string xsltFileName;

private string xmlBaseDirectoryPath;
private string xmlFileName;

private bool digest;
private bool disableEscaping;

private NSOtherLogger logger;

public ComplexTransformation()
{}

public ComplexTransformation(string instanceName)
{
this.xsltBaseDirectoryPath = null;
this.xsltFileName = null;

this.xmlBaseDirectoryPath = null;
this.xmlFileName = null;

this.initialised = false;
this.disableEscaping = false;

string logText =
NSStringResource.GetLocaleString(NSLocaleStringEnum.XsltFormatterComponentName);
this.logger = new NSOtherLogger(instanceName, logText);

}

public void Initialize(StringDictionary arguments, bool digest)
{
if (!this.initialised)
{
if (!arguments.ContainsKey("XsltFileName"))
{
throw new NSException(NSEventEnum.XsltFileNameTagMissing);
}

if (!arguments.ContainsKey("XsltBaseDirectoryPath"))
{
throw new NSException(NSEventEnum.XsltBaseDirectoryPathTagMissing);
}

if (!arguments.ContainsKey("XmlFileName"))
{
throw new NSException("Input XML path tag missing");
}

if (!arguments.ContainsKey("XmlBaseDirectoryPath"))
{
throw new NSException("Input XML base directory path tag missing");
}

this.xsltBaseDirectoryPath = arguments["XsltBaseDirectoryPath"];
this.xsltFileName = arguments["XsltFileName"];
this.xmlBaseDirectoryPath = arguments["XmlBaseDirectoryPath"];
this.xmlFileName = arguments["XmlFileName"];

if (arguments.ContainsKey("DisableEscaping"))
{
try
{
this.disableEscaping = bool.Parse(arguments["DisableEscaping"]);
}
catch (Exception exception1)
{
NSEventParameters parameters1 = new NSEventParameters();
parameters1.AddParameter(NSEventParamEnum.XsltDisableEscapingValue,
arguments["DisableEscaping"]);
throw new NSException(NSEventEnum.XsltDisableEscapingValueInvalid,
parameters1, exception1);
}
}
this.digest = digest;
this.initialised = true;
}
}


public string FormatContent(string subscriberLocale, string
deviceTypeName, RecipientInfo recipientInfo, Hashtable[] rawContent)
{
string XmlLocation = this.xmlBaseDirectoryPath + this.xmlFileName;
string XsltLocation = this.xsltBaseDirectoryPath + this.xsltFileName;
RenderVariables(XmlLocation);
string outputXHTML = null;

try
{
outputXHTML = this.Transform(XmlLocation,XsltLocation);
}
catch (Exception FormatException)
{
NSException ThrownException = FormatException as NSException;
if (ThrownException == null)
{
ThrownException = new
NSException(NSEventEnum.XsltFormatterUnknownError, FormatException);
}
this.logger.LogError(ThrownException);
throw ThrownException;
}
return outputXHTML;
}

private void RenderVariables(string Variable)
{
// create a writer and open the file
TextWriter tw = new StreamWriter(@"C:\Dump.txt");

// write a line of text to the file
tw.WriteLine(Variable);

// close the stream
tw.Close();
}


public void Close()
{
}

public string Transform(string XmlPath, string XslPath)
{
string NullString = null;

XPathDocument XPathDocument;
XslTransform XslTrans;

// Create the output stream
StringBuilder DocStringBuilder;
TextWriter DocTextWriter = null;

try
{
// Read XML
XPathDocument = new XPathDocument(XmlPath);

// Create a new XslTransform object.
XslTrans = new XslTransform();
// Load the stylesheet.
XslTrans.Load(XslPath);

// Create the output stream
DocStringBuilder = new StringBuilder();
DocTextWriter = new StringWriter(DocStringBuilder);

XslTrans.Transform(XPathDocument,null,DocTextWriter);

}
catch (XsltException TransformException)
{
NSEventParameters EventParameters = new NSEventParameters();
EventParameters.AddParameter(NSEventParamEnum.XsltTransformFile,
NullString);
throw new NSException(NSEventEnum.XsltInvalidTransform, EventParameters,
TransformException);
}
finally
{
DocTextWriter.Close();
}

// Push result
return DocStringBuilder.ToString();
}

}
}

Any idea on a resolution?

Joe

Colin Meek

unread,
Sep 27, 2005, 6:42:30 PM9/27/05
to
This looks like a .NET version mismatch problem. Which versions of NS and
the .NET framework are installed on your server machine? Is upgrading to
.NET 1.1 and NS 2.0 SP1 an option?

--
Colin Meek
SQL Server Notification Services

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at

http://www.microsoft.com/info/cpyright.htm.
"Joe" <J...@discussions.microsoft.com> wrote in message
news:C71BDA2E-0636-42B8...@microsoft.com...

Colin Meek

unread,
Sep 28, 2005, 1:47:07 PM9/28/05
to
Joe --

NS 2.0 SP1 supports the .NET 1.0 and 1.1 runtimes.

If the 1.0.3705 runtime is available, NS _should_ be launching against that
version (order matters). Just to troubleshoot, see if removing the v1.1.4322
<supportedRuntime> element resolves the problem. This will also confirm that
the 1.0.3705 runtime is available to the service.

- Colin

--
Colin Meek
SQL Server Notification Services

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.

"Joe" <J...@discussions.microsoft.com> wrote in message

news:96C70451-8D08-4884...@microsoft.com...
> Hi Colin
>
> We have Notification Services 2.0 Service Pack 1 with .NET v's 1.0 & 1.1.
>
> i've added:
>
> <startup>
> <supportedRuntime version="v1.0.3705"/>
> <supportedRuntime version="v1.1.4322"/>
> </startup>
>
> To NSService.exe.config to try and specify which versions of the CLR NS is
> to support, but this hasn't made a difference.
>
> What does NS 2.0 SP1 run under?
>
> Joe


Dan Legesse [MSFT]

unread,
Sep 28, 2005, 2:27:20 PM9/28/05
to
Hi Joe,

> Request for the permission of type
> System.Security.Permissions.StrongNameIdentityPermission, mscorlib,
> Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
> failed.

A strong named assembly (in this case NS) is not allowed to load a
non-strong named assembly. That is what this error indicates. Make sure
that your custom formatter assembly is strong named.

If all of your custom components are built using the 1.0 Framework, you
don't need to add the <supportedRuntime> elements in the config file.

Dan

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.


"Colin Meek" <cm...@alias.microsoft.com> wrote in message
news:ee5JtSF...@TK2MSFTNGP11.phx.gbl...

0 new messages