473,587 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to add assembly reference to an ASP.NET page with XML/XSL transform

I have an ASP.NET page that uses a tag:

<asp:Xml id="foo" runat="server" DocumentSource= "rss.xml" TransformSource ="rss20.xsl" />

This creates a Web page from an XML file that was generated by InfoPath. By default InfoPath inline's their images in base64 encoding. These need to be extracted out to be displayed.

I've got my XSL set up to be able to pull out images and manage them separately. According to Microsoft, they need to be decoded and returned back as an image stream to the src attribute of the img tag.

See: http://www.mcse.ms/archive180-2004-4-605843.html
See: http://blogs.msdn.com/infopath/archi...21/117600.aspx

So I've got some C# code in my XSL that performs this decode operation -- well, that's where I need help. Here's the code:

<msxsl:script language="C#" implements-prefix="cs">
<![CDATA[
Image decode(string s)
{
byte[] image = Convert.FromBas e64String( s );
System.IO.Memor yStream memStr = new System.IO.Memor yStream();
memStr.Write( image, 0, image.Length );
System.Drawing. Image img = System.Drawing. Image.FromStrea m(memStr);
return image;
}
]]>
</msxsl:script>

The problem I'm hitting is that the process is failing on System.Drawing. Image -- it doesn't know what it is. Here's what I get back:
>>>>>>>>>

Server Error in '/' Application.
--------------------------------------------------------------------------------

Script compile errors: file:///c:/inetpub/wwwroot/rss20.xsl(8,1) : error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Xml.Xsl. XsltException: Script compile errors: file:///c:/inetpub/wwwroot/rss20.xsl(8,1) : error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)
<<<<<<<<<<<<< <

So my question is how do I add an assembly reference to System.Drawing, and where? This is an ASP.NET page with an XML/XSL transform. I don't have a whole lot of .NET knowledge -- I only JUST discovered I can actually even use C# in XSL (I just tried it out of pure curiosity -- and that gave me some hope!)

Anyone know how to add this assembly reference and where? Thanx!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

Nov 18 '05 #1
5 8910
Sorry, one modification to the return value of the code, and a slightly different error:

<msxsl:script language="C#" implements-prefix="cs">
<![CDATA[
System.Drawing. Image decode(string s)
{
byte[] image = Convert.FromBas e64String( s );
System.IO.Memor yStream memStr = new System.IO.Memor yStream();
memStr.Write( image, 0, image.Length );
System.Drawing. Image img = System.Drawing. Image.FromStrea m(memStr);
return image;
}
]]>
</msxsl:script>
Error:
Script compile errors: file:///c:/inetpub/wwwroot/rss20.xsl(8,8) : error CS0234: The type or namespace name 'Drawing' does not exist in the class or namespace 'System' (are you missing an assembly reference?)
I've also tried adding to the .aspx page, with no luck, the following:
<%@ import namespace="Syst em.Drawing" %>

I know System.Drawing is there, because if I purposely misspell it to "System.Drawing foo" then I get an error on this import line.

I've also tried using an import with System.Drawing. Image, with no luck.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com


"Greg Collins [MVP]" <Greg.Collins_A T_InfoPathDev.c om> wrote in message news:#X******** ******@TK2MSFTN GP15.phx.gbl...
I have an ASP.NET page that uses a tag:

<asp:Xml id="foo" runat="server" DocumentSource= "rss.xml" TransformSource ="rss20.xsl" />

This creates a Web page from an XML file that was generated by InfoPath. By default InfoPath inline's their images in base64 encoding. These need to be extracted out to be displayed.

I've got my XSL set up to be able to pull out images and manage them separately. According to Microsoft, they need to be decoded and returned back as an image stream to the src attribute of the img tag.

See: http://www.mcse.ms/archive180-2004-4-605843.html
See: http://blogs.msdn.com/infopath/archi...21/117600.aspx

So I've got some C# code in my XSL that performs this decode operation -- well, that's where I need help. Here's the code:

<msxsl:script language="C#" implements-prefix="cs">
<![CDATA[
Image decode(string s)
{
byte[] image = Convert.FromBas e64String( s );
System.IO.Memor yStream memStr = new System.IO.Memor yStream();
memStr.Write( image, 0, image.Length );
System.Drawing. Image img = System.Drawing. Image.FromStrea m(memStr);
return image;
}
]]>
</msxsl:script>

The problem I'm hitting is that the process is failing on System.Drawing. Image -- it doesn't know what it is. Here's what I get back:
>>>>>>>>>

Server Error in '/' Application.
--------------------------------------------------------------------------------

Script compile errors: file:///c:/inetpub/wwwroot/rss20.xsl(8,1) : error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Xml.Xsl. XsltException: Script compile errors: file:///c:/inetpub/wwwroot/rss20.xsl(8,1) : error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?)
<<<<<<<<<<<<< <

So my question is how do I add an assembly reference to System.Drawing, and where? This is an ASP.NET page with an XML/XSL transform. I don't have a whole lot of .NET knowledge -- I only JUST discovered I can actually even use C# in XSL (I just tried it out of pure curiosity -- and that gave me some hope!)

Anyone know how to add this assembly reference and where? Thanx!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

Nov 18 '05 #2
PL

I had the exact same problem trying to do sql queries inside a msxsl:script block.

I posted a question about that a while ago and got no helpful replies at all.

The only thing I could deduct is that it's actually a documentation error,
that is you cannot use ANY assembly inside a script block, only the
listed default ones.

One way to solve I guess is to skip the inline xmlns:script blocks and
attach an object to the transform instead, there are some articles about
how to do that.

Then you just write your own class and attach it, then call whatever methods
you need from inside the xls.

Let me know if you find another solution, seems this should work accroding to docs.

PL.

"Greg Collins [MVP]" <Greg.Collins_A T_InfoPathDev.c om> wrote in message news:Oj******** ******@TK2MSFTN GP15.phx.gbl...
Sorry, one modification to the return value of the code, and a slightly different error:

[snip]
Nov 18 '05 #3
What were the steps you used to make this work? I'm still fairly new to ASP.NET, C# and the .NET Framework, so specifics, or even a walkthrough, would be helpful.

By the way, another change to the code quoted earlier is that I would be returning "img" and not "image". (Sorry -- I was doing a lot of playing around with the code earlier, and pasted it in to the posting before cleaning it back up, so I missed a few things) :o)

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"PL" <pb****@yahoo.s e> wrote in message news:eF******** ******@tk2msftn gp13.phx.gbl...

I had the exact same problem trying to do sql queries inside a msxsl:script block.

I posted a question about that a while ago and got no helpful replies at all.

The only thing I could deduct is that it's actually a documentation error,
that is you cannot use ANY assembly inside a script block, only the
listed default ones.

One way to solve I guess is to skip the inline xmlns:script blocks and
attach an object to the transform instead, there are some articles about
how to do that.

Then you just write your own class and attach it, then call whatever methods
you need from inside the xls.

Let me know if you find another solution, seems this should work accroding to docs.

PL.

"Greg Collins [MVP]" <Greg.Collins_A T_InfoPathDev.c om> wrote in message news:Oj******** ******@TK2MSFTN GP15.phx.gbl...
Sorry, one modification to the return value of the code, and a slightly different error:

[snip]
Nov 18 '05 #4
PL
> What were the steps you used to make this work? I'm still fairly new to ASP.NET,
C# and the .NET Framework, so specifics, or even a walkthrough, would be helpful.
Actually the samples are pretty few on this subject as well but you use the AddExtensionObj ect
and AddParam in the XsltArgumentLis t class.

These articles have some .NET examples in them (look somewhere at the bottom of both):
http://msdn.microsoft.com/msdnmag/issues/02/03/xml/
http://msdn.microsoft.com/library/de...hancingxsl.asp

Here's a sample from the first MS article, in this sample they created a class called Person
with the public method SayHello and then add it to the transform with AddExtensionObj ect

The XSL:

<xsl:transfor m version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:obj="urn: person"

<xsl:output method="text"/>
<xsl:template match="/">
name: <xsl:value-of select="obj:get-name()"/>
age: <xsl:value-of select="obj:get-age()"/>
greeting: <xsl:value-of select="obj:Say Hello('Michi')"/>
</xsl:template>
</xsl:transform>

The VB.NET code

XslTransform xslt = new XslTransform();
xslt.Load(style sheet);
XPathDocument doc = new XPathDocument(f ilename);
XsltArgumentLis t xslArg = new XsltArgumentLis t();

// Create a Person object
Person obj = new Person();
obj.name = "Michi";
obj.age = 6;

// Add it to the transform
xslArg.AddExten sionObject("urn :person", obj);
xslt.Transform( doc, xslArg, Console.Out);

Hope this helps.
PL.
Nov 18 '05 #5
Hi Greg,

PL's answer is correct, you'd better use extension objects. I am responsible
to fix this problem in Framework 2.0. If you have Beta1, you may try the
following:

<msxsl:script language="..." implements-prefix="...">
<msxsl:assemb ly name="myassembl y.dll"/>
...
</msxsl:script>

Thanks,
Anton

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2004 Microsoft Corporation. All rights
reserved.
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9397
by: Mountain Bikn' Guy | last post by:
This code (adapted from the examples in the docs) doesn't make complete sense to me. I have it working, but I'm wondering why I need to declare an assembly reference in 2 places. TIA. Dave CodeCompileUnit compileUnit = new CodeCompileUnit(); CodeNamespace myNamespace = new CodeNamespace("MyNamespace"); compileUnit.Namespaces.Add( myNamespace ); compileUnit.ReferencedAssemblies.Add(@"MyDLL.dll");//I declare an assembly reference here...
3
1026
by: Helene Day | last post by:
I am trying to access the Word Objects from a .NET project. I have some sample from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/WordObject.asp and I have MS Office 2003. However I don't know which file I need to reference for the MS Word 11.0 Object Library. Or what else do I need to install/download from MS to be able to create MS Office 2003 Projects.
2
2011
by: PL | last post by:
According to the documentation I'm supposed to be able to use any classes in the ..NET framework inside a msxml:script block if I use a fully qualified path. I'm trying to test the XSL sheet below with ASP.NET and all I'm getting is: error CS0234: The type or namespace name 'Data' does not exist in the class or namespace 'System' (are you missing an assembly reference?) Could someone explain how you reference these classes from...
1
2896
by: Rui Macdonald | last post by:
I trying some asp from angGoGo PhotoControl and when I star it on my computer always gives the following message, Can you please help me? :-( ------------------------------------------- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileLoadException: The...
3
4392
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here really understand how this could be an issue. The assemblies that the system is complaining about are ones that we build here and we're not changing version numbers on anything. The errors come and go with no apparent rhyme or reason. We do not...
0
1985
by: =?Utf-8?B?SmFtZXM=?= | last post by:
I'm stuck with the following error... Does anyone know how to correct the reference? I've not idea why it is referencing 'Copy of...' Server Error in '/Client1' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file
4
14614
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I developed, and ran successfully, a web application on my development box, but cannot get it to run on the server. The error I am getting is: Compiler Error Message: CS0234: The type or namespace name 'Packaging' does not exist in the namespace 'System.IO' (are you missing an assembly reference?) I have installed .Net framework 3.5 and 2007 Office System: Microsoft SDK for Open XML Formats, but that has not resolved the problem.
0
1375
by: JB | last post by:
I have an ASP project written years ago that I have recently started to try and update. It was written by someone who used to work here before me, and the source code I have is in a major mess. There is just one (of many) DLL file that once I recompile I get the error mentioned above. The located assembly's manifest definition with name '.....' does not match the assembly reference (see snippet for full detail).
2
5128
by: Febria | last post by:
Dear, all... I have some problem with my application. I used UltraWebGrid component in my web application. Unfortunately, when I tried to run the web, the error page displayed: The located assembly's manifest definition with name 'Infragistics.WebUI.UltraWebGrid.v3' does not match the assembly reference. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for...
0
7924
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7978
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.