Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Compilation Error when creating XML Web Service

I am going through the guided tour of Web Matrix and currently going through the steps of "Create a new XML Web Service". 

Let me tell you first the steps I have taken before running the code and then I will tell you the error message that I am getting. 

On the 'Add New File' dialogue window, I selected 'General' under the 'Templates' list on the left side of the window, selected 'XML Web Service' icon on the right, typed 'Sample' in the 'Class' textbox and 'MatrixDemo' in the 'Namespace' textbox, clicked OK button and finally ran the code (without making any changes). 

This gives me the following error message:

**************Begin Error Message***********
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1595: 'System.IO.StringWriter' is defined in multiple places; using definition from 'C:\winnt\\framework\v1.0.3705\mscorlib.dll'

Source Error:
Line 45:    OperationBinding httpPostOperationBinding;
Line 46:    Operation httpPostOperation;
Line 47:    StringWriter writer;
Line 48:    MemoryStream xmlSrc;
Line 49:    XmlTextWriter xmlWriter;

Source File: c:\winnt\\framework\v1.0.3705\Config\DefaultWsdlHelpGenerator.aspx    Line: 47

**************End Error Message***********

One of the solution I found was to go into Machine.Config file and look for:

<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="1" />

and change the 'warningLevel' above from 1 to 0, save the file and then re-run the code.  It worked! 

My questions is: Is there any other solution besides that?  I do not like to change the warning level to 0 which, I am not sure, may or may not be the right thing to do when working on a real project. 

My next problem: 
Once I change the warning level to 0 and then run the above code, it works fine and shows me 'Add' as an available operation option.  When I click on Add, it gives me two text boxes in which I have to enter two intergers and then click 'Invoke' button. 

The Web service should return an XML response that gives the difference of the two input parameters in a new instance of your Web browser, BUT it doesn't! and throws the following error:

***************Begin error message**************
System.IO.FileNotFoundException: File or assembly name xnygojzf.dll, or one of its dependencies, was not found.
File name: "xnygojzf.dll"
  at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
  at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
  at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
  at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
  at System.Xml.Serialization.Compiler.Compile()
  at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings)
  at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings)
  at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
  at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
  at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
  at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
  at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
  at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

Fusion log follows:
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\WINNT\TEMP\xnygojzf.dll
LOG: Appbase = file:///D:/dotNET Related/My dotNET Learning Project
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).

LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINNT/TEMP/xnygojzf.dll.
***************End error message**************

I can't find any clue on this anywhere on the web.  I will appreciate any help on this.  Thanks. 


Thursday, December 5, 2002

*  Recent Topics

*  Fog Creek Home