locked
Could not open Schema.xsd.cs file(unspecified error).... What is this error??? RRS feed

  • Question

  • Hi,

    We have a BizTalk setup, which has been installed and re-installed due to service pack updates etc.,

    Ultimately, when we created a sample BizTalk project with a single .xsd file.. we get the following error.

    VS auto-generates a .cs file (eg: Sample.xsd.cs) for every .xsd file(eg:Sample.xsd) that is in the project.

    However, our VS doesn't generate any and it gives the error that it couldn't find/open the .cs file.

    Any pointers would be greatly helpful on how to resolve it.

     

    Regards

    Praveen.


    praveen
    Tuesday, April 27, 2010 10:00 AM

Answers

  • I've just stumbled across exactly the same issue trying to configure multiple development environments and a TFS automated build solution. I noted that:

    1) Checking out a single XSD file does not result in the corresponding CS file being created

    2) Excluding the XSD file from the project then re-including it does result in the CS file being created

    3) Checking out just the BTPROJ file and the XSD file (expecting this perhaps to be similar to the exclude / re-include) does not result in the corresponding CS file being created

    4) As detailed above, checking out every file in the solution prior to build addresses the problem.

    Okay, there must be a minimum combinations of files that I can check out to allow CS file generation, but I don't have time to iterate through the permutations atm :S

    Tuesday, June 8, 2010 3:40 PM
  • I was also facing the same error.

    The resolution provided in the following post worked for me:

    http://bloggingabout.net/blogs/markwillems/archive/2011/02/16/biztalk-schema-build-error.aspx

    After removing the read-only flag from the folder I was able to build again.

     

    Regards

    Anoop

     


    Anoop Gupta

    BizTalk Developer

    Monday, March 28, 2011 10:22 AM

All replies

  • Hi Praveen,

    You can try using process monitor as a diagnostic tool and look at real-time file system, Registry, while you are reproducing this error filtering on devenv.exe. Possibly a setting in registry cannot be accessed or certain assembly cannot be found.

    HTH

    Regards,

    Steef-Jan Wiggers
    MCTS BizTalk Server
    http://soa-thoughts.blogspot.com/
    If this answers your question please mark it accordingly

     


    BizTalk
    Tuesday, April 27, 2010 10:04 AM
    Moderator
  • Hi Steef,

    Thanks for responding. It seems like a great tool, but didn't understand what to monitor when the error is reproduced. I will see if I can resolve it by re-installing the entire of Biztalk, VS etc.,

    Regards
    Praveen.


    praveen
    Tuesday, April 27, 2010 11:26 AM
  • Hi Praveen,

    Try to repair BizTalk/VS first before going through a complete reinstall. It can save you time and probleem might be resolved.

    Regards,

    Steef-Jan Wiggers
    MCTS BizTalk Server
    http://soa-thoughts.blogspot.com/
    If this answers your question please mark it accordingly


    BizTalk
    Tuesday, April 27, 2010 11:28 AM
    Moderator
  • Are you getting any errors in the eventlog when you try to open your .cs files. Also make sure that you build the project in development mode and refresh the project after the build. 

    Also does this sample schema project build(development mode) without any errors and warnings.

     


    Regards,
    Bali
    MCTS: BizTalk Server
    --------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Tuesday, April 27, 2010 2:17 PM
  • Hi Steef/DBali,

    I have done a complete new installation after removing Biztalk, VS, SQL Server 2005, .NET frameworks. After all the entire reinstallation without any hiccup, I even configure Biztalk successfully. Even after that, I create a new project and it gives me the same error message.. :(

    Source file <path>\SampleSchema.xsd.cs could not be opened (Unspecified error)

    Additionally, I tried instantiating the xsd and it gave me "Custom component invocation failed." :'(
    I don't know what to do now.. Is it some problem with the installation files itself???

    Regards
    Praveen.


    praveen
    Wednesday, April 28, 2010 2:46 PM
  • Which is the BizTalk version you are installing?
    Do you think your installable itself is corrupted? (just a guess). I believe you have already installed Biztalk SDK.
    Is this something you are getting error while creating project from visual studio while adding new schema file? Can you create simple messaging application from Administrator Console itself? Anything else written in event log (before/after your action).

    What you have done in this: Additionally, I tried instantiating the xsd


    Please mark it as Answer if this answers your question
    Thanks.
    Mo
    Wednesday, April 28, 2010 3:20 PM
  • Thursday, April 29, 2010 2:53 AM
  • Hi Mohan,
    I am using Biztalk 2009 on a 32 bit Windows 2003 OS. I have installed the following in this order..
    .NET 2.0
    .NET 3.0
    .NET 3.5
    SQL Server 2005
    SQL 2005 SP2
    VISUAL STUDIO 2008
    VS2008 SP1
    Biztalk 2009 & configuration

    After that, I restart my machine, created a brand new BT project.
    Added one single schema. The root node is SampleSchema and two item nodes item1, item2.
    When I compile, I get this error..
    Source file <path>\SampleSchema.xsd.cs could not be opened (Unspecified error)

    @Raja,
    Thanks a lot for the link.. I got to know a different aspect but not the solution to my issue.
    See.. On a properly working machine(call it GoodMac).. When I create a Schema project, it compiles and in process creates a .xsd.cs file for every .xsd file.
    On the not working machine(call it BadMac)... When I create the same solution and compile it.. it doesn't compile. And yes, it never creates that .xsd.cs file for any of the .xsd files.

    Hope, I have explained it in detail.

    Regards
    Praveen.


    praveen
    Thursday, April 29, 2010 7:09 AM
  • Hi Mohan,
    In my first tries, I just compiled the project and got the source file not found error.
    When I said additionally, I meant - I tried instantiating the .xsd and this also didn't work.(This I have done after I reinstalled the whole stack).
    I am not sure if my installable itself is corrupt.. this is a common installable we use and there were never any complaints.. however, I don't have any other machines where I can try installation again. :(
    Adding the schema happens, but "Generate Instance" and "Compilation" doesn't happen.
    There is nothing that is written to the event log before or after.

    I haven't tried creating any other sample messaging solution from the Admin console.
    I will do that and get back to you.
    But that means, I might have to use a PassThruReceive etc., to design the solution.

    Another thing, what component is exactly invoked when we try to Generate an instance or when the xsd itself is compiled??

    Regards
    Praveen.


    praveen
    Thursday, April 29, 2010 7:20 AM
  • Hi,

    Just to make sure, did you install the C# parts when installing Visual Studio?

     


    HTH,

    Randal van Splunteren - MVP, MCTS BizTalk Server
    http://biztalkmessages.vansplunteren.net

    Please mark as answered if this answers your question.

    Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.com
    Thursday, April 29, 2010 7:50 AM
    Moderator
  • Hi Randal,

    During the installation... on the VS option selection screen, I went for custom installation. Over there, I selected custom, went to the next screen.. over there unchecked SQLExpress and Crystal Reports. All others, I have left them with the default values.. I am sure that it installs all except for some very specific components. The C# thing would be installed I believe. Let me know if you are exactly looking for something.

    Meanwhile.. any idea as to what component is invoked by VS in order to generate an instance from a schema??

    Ok.. one more step that we have done is.. we compiled the solution on my machine.. It automatically created the .xsd.cs files. I manually copy pasted the .xsd.cs file from my system onto the machine where all this issue is happening.. Even when I copy it.. the error remained the same. To top it, it shows the copied .xsd.cs files in the Solution Explorer below the respective .xsd file with a Information Incon (triangle with an exclamation mark) in it.

    - Praveen.


    praveen
    Thursday, April 29, 2010 8:40 AM
  • In the properties page of the schema file, set the

    "Build Action" property to BtsCompile, this will generate the .cs file and hopefully should resolve your issue


    Regards, Saravana Kumar [MVP BizTalk Server] http://blogs.digitaldeposit.net/saravana/ http://www.biztalk247.com/
    Thursday, April 29, 2010 8:52 AM
    Moderator
  • Hi Saravana,

    BtsCompile is the default option when a schema is created. Only when the option is present VS actually tries compiling and in the process gives out the error. If it is set to "None", the project compiles without issues. But when you deploy none of schemas actually get deployed.


    praveen
    Thursday, April 29, 2010 10:24 AM
  • Are you using any sourcecontrol? Do you think the file in sourcecontrol itself is currupted which is causing problem in newly installed machine and other developers are using old version? To check this, you can take the backup of the code in working machine, and take the fresh version from source control and try compiling on other machine.


    Please mark it as Answer if this answers your question
    Thanks.
    Mo
    Thursday, April 29, 2010 11:06 AM
  • Hi Mohan,

    We can leave Source Control out of our discussion. I am talking about freshly installed configuration and a brand new solution, with just 1 BT project which has 1 schema added.

    What component is invoked by VS inorder to generate those .xsd.cs file.. What compiles those schemas?? Is there any permission or local policy issues that I am not seeing??

    - Praveen.


    praveen
    Thursday, April 29, 2010 6:03 PM
  • Hi Mohan,

    We can leave Source Control out of our discussion. I am talking about freshly installed configuration and a brand new solution, with just 1 BT project which has 1 schema added.

    What component is invoked by VS inorder to generate those .xsd.cs file.. What compiles those schemas?? Is there any permission or local policy issues that I am not seeing??

    - Praveen.


    praveen

     

    If you need the code for the XSD files you can probably use 2 good open source tools on codeplex. I am using WCF blue which is an addon with the VS2008. Of course you can use the one which comes with VS (XML Schema Definition Tool (Xsd.exe).

    1- WCF Blue (http://wscfblue.codeplex.com/wikipage)
    2- XSD2Code (Xsd2Code .net class generator from XSD schema )

    I am not sure what VS uses behind the scenes to generate the cs files for xsd. But if you want to explicitly generate CLR types in a .cs file you can use xsd tool. It will generate the CLR types for you which you can use in your code. XML Schema Definition Tool (Xsd.exe)


    Abdul Rafay - MVP & MCTS BizTalk Server
    blog: http://abdulrafaysbiztalk.wordpress.com/
    Please mark this as answer if it helps.
    Thursday, April 29, 2010 8:51 PM
  • Hi Abdul,

    Just to make it more clear... the .xsd.cs is not the same file as that of the .cs file that we generate using the xsd.exe utility. The schema I used has a root 'Sample' and one filed 'filename'. This field is both Property Promoted and Distinguished promoted. Please note, I have even tried without any promotion and got the same error.
    You can spot the difference in the below extracts...

    SampleSchema.xsd.cs (this is auto-generated by VS)
    =====================================
    namespace PromotionProject {
        using Microsoft.XLANGs.BaseTypes;
       
       
        [SchemaType(SchemaTypeEnum.Document)]
        [Schema(@"http://PromotionProject.SampleSchema",@"Sample")]
        [Microsoft.XLANGs.BaseTypes.PropertyAttribute(typeof(PromotionProject.PropertySchema.filename), XPath = @"/*[local-name()='Sample' and namespace-uri()='http://PromotionProject.SampleSchema']/*[local-name()='filename' and namespace-uri()='']", XsdType = @"string")]
        [Microsoft.XLANGs.BaseTypes.DistinguishedFieldAttribute(typeof(System.String), "filename", XPath = @"/*[local-name()='Sample' and namespace-uri()='http://PromotionProject.SampleSchema']/*[local-name()='filename' and namespace-uri()='']", XsdType = @"string")]
        [System.SerializableAttribute()]
        [SchemaRoots(new string[] {@"Sample"})]
        [Microsoft.XLANGs.BaseTypes.SchemaReference(@"PromotionProject.PropertySchema.PropertySchema", typeof(PromotionProject.PropertySchema.PropertySchema))]
        public sealed class SampleSchema : Microsoft.XLANGs.BaseTypes.SchemaBase {
           
            [System.NonSerializedAttribute()]
            private static object _rawSchema;
           
            [System.NonSerializedAttribute()]
            private const string _strSchema = @"<?xml version=""1.0"" encoding=""utf-16""?>
    <xs:schema xmlns:ns0=""https://PromotionProject.PropertySchema"" xmlns:b=""http://schemas.microsoft.com/BizTalk/2003"" xmlns=""http://PromotionProject.SampleSchema"" targetNamespace=""http://PromotionProject.SampleSchema"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
      <xs:annotation>
        <xs:appinfo>
          <b:imports>
            <b:namespace prefix=""ns0"" uri=""https://PromotionProject.PropertySchema"" location=""PromotionProject.PropertySchema.PropertySchema"" />
          </b:imports>
        </xs:appinfo>
      </xs:annotation>
      <xs:element name=""Sample"">
        <xs:annotation>
          <xs:appinfo>
            <b:properties>
              <b:property name=""ns0:filename"" xpath=""/*[local-name()='Sample' and namespace-uri()='http://PromotionProject.SampleSchema']/*[local-name()='filename' and namespace-uri()='']"" />
              <b:property distinguished=""true"" xpath=""/*[local-name()='Sample' and namespace-uri()='http://PromotionProject.SampleSchema']/*[local-name()='filename' and namespace-uri()='']"" />
            </b:properties>
          </xs:appinfo>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name=""filename"" type=""xs:string"" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>";
           
            public SampleSchema() {
            }
           
            public override string XmlContent {
                get {
                    return _strSchema;
                }
            }
           
            public override string[] RootNodes {
                get {
                    string[] _RootElements = new string [1];
                    _RootElements[0] = "Sample";
                    return _RootElements;
                }
            }
           
            protected override object RawSchema {
                get {
                    return _rawSchema;
                }
                set {
                    _rawSchema = value;
                }
            }
        }
    }


    SampleSchema.cs (this is generated using xsd.exe)
    ====================================
    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:2.0.50727.3603
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------

    using System.Xml.Serialization;

    //
    // This source code was auto-generated by xsd, Version=2.0.50727.3038.
    //


    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://PromotionProject.SampleSchema")]
    [System.Xml.Serialization.XmlRootAttribute(Namespace="http://PromotionProject.SampleSchema", IsNullable=false)]
    public partial class Sample {
       
        private string filenameField;
       
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string filename {
            get {
                return this.filenameField;
            }
            set {
                this.filenameField = value;
            }
        }
    }


    Praveen Behara
    MCST : BizTalk Server 2006 R2
    Friday, April 30, 2010 12:50 PM
  • HI All,

    As an update, I have generated a .cs file using the xsd.exe and renamed the output .cs file to .xsd.cs file. The compiler compiled the code successfully and even deployed it. However, I can see the file as deployed but the schemas are never seen in the list of schemas. :(


    Praveen Behara
    MCST : BizTalk Server 2006 R2
    Sunday, May 2, 2010 7:46 PM
  • In the Biztalk administration console check in the All artifacts node -> Schemas that your schema is in the list. Did you see the deploy success in the visual studio output window? In order to confirm that the schemas were deployed correctly and are present in the Btsmgmtdb database you can read my blog post (Verifying Schemas after deployment) where you can run the direct query.

    Select msgtype, assemblyid, clr_namespace, clr_assemblyname
    from bt_documentspec
    where msgtype = ‘http://mycompany.schema#orders’


    Abdul Rafay - MVP & MCTS BizTalk Server
    blog: http://abdulrafaysbiztalk.wordpress.com/
    Please mark this as answer if it helps.
    Monday, May 3, 2010 5:20 AM
  • Hi,

    You're encountering very strange problems. In your case I would rebuild the BizTalk machine by installing it from scratch.


    HTH,

    Randal van Splunteren - MVP, MCTS BizTalk Server
    http://biztalkmessages.vansplunteren.net

    Please mark as answered if this answers your question.

    Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.com
    Monday, May 3, 2010 7:00 AM
    Moderator
  • Hi Abdul,

    As I mentioned, the dll is seen as deployed.. however the schemas never got deployed. I have used your above query (with of course changed msgtype) and it hasn't returned any rows. I manually checked it and it has no corresponding schemas to that of my DLL.


    Praveen Behara
    MCST : BizTalk Server 2006 R2
    Tuesday, May 4, 2010 1:47 PM
  • Hi Randal,

    It is true that it is pretty strange.. haven't encountered any such issue in the past. And this machine was a 'working' dev machine.. and we aren't sure if we started encountering this after making any changes or installing new software. There is pretty little help on the net for this :( Currently, we are compiling DLLs elsewhere and deploying them here.


    Praveen Behara
    MCST : BizTalk Server 2006 R2
    Tuesday, May 4, 2010 1:49 PM
  • Hi Randal,

    Rebuilding the entire machine is not an option for us.. maybe that would work, but we would like to find out what is actually going wrong and where. We are going to use the same installables on a laptop this time and see if there is any issue. I would update you all on this.


    Praveen Behara
    MCST : BizTalk Server 2006 R2
    Tuesday, May 11, 2010 3:20 PM
  • Hi Praveen

    I experienced that very same problem. In my case the cause of the problem was that the Read-only attribute was set on the .xsd-files. After removing this my project build allright.

     

     

     

    Thursday, June 3, 2010 9:29 AM
  • Hi Praveen,

    We found the issue to be source control-related. We had to make sure every file in the solution was checked out for edit, this fixed the problem.

    Regards,

    Andrew

    Monday, June 7, 2010 10:58 AM
  • I've just stumbled across exactly the same issue trying to configure multiple development environments and a TFS automated build solution. I noted that:

    1) Checking out a single XSD file does not result in the corresponding CS file being created

    2) Excluding the XSD file from the project then re-including it does result in the CS file being created

    3) Checking out just the BTPROJ file and the XSD file (expecting this perhaps to be similar to the exclude / re-include) does not result in the corresponding CS file being created

    4) As detailed above, checking out every file in the solution prior to build addresses the problem.

    Okay, there must be a minimum combinations of files that I can check out to allow CS file generation, but I don't have time to iterate through the permutations atm :S

    Tuesday, June 8, 2010 3:40 PM
  • N.b. After the CS files have been build you could always add them to TFS.  Once you do have an environment where the CS files have been generated:

    1) Click the "Show All Files" option in Solution explorer

    2) Close then re-open Visual Studio (this allows VS to recognise that the CS files are dependancies of the XSD files)

    3) Select each hidden CS file in turn, right-click and "Add to Project"

    Tuesday, June 8, 2010 4:00 PM
  • I was also facing the same error.

    The resolution provided in the following post worked for me:

    http://bloggingabout.net/blogs/markwillems/archive/2011/02/16/biztalk-schema-build-error.aspx

    After removing the read-only flag from the folder I was able to build again.

     

    Regards

    Anoop

     


    Anoop Gupta

    BizTalk Developer

    Monday, March 28, 2011 10:22 AM
  • I've just stumbled across exactly the same issue trying to configure multiple development environments and a TFS automated build solution. I noted that:

    1) Checking out a single XSD file does not result in the corresponding CS file being created

    2) Excluding the XSD file from the project then re-including it does result in the CS file being created

    3) Checking out just the BTPROJ file and the XSD file (expecting this perhaps to be similar to the exclude / re-include) does not result in the corresponding CS file being created

    4) As detailed above, checking out every file in the solution prior to build addresses the problem.

    Okay, there must be a minimum combinations of files that I can check out to allow CS file generation, but I don't have time to iterate through the permutations atm :S

    Hi

    Excluding the files from the project, and then including them lead to total success !!

    A great thanks to Kev666n !!!

    Friday, March 16, 2012 2:37 PM
  • Hi,

    Thanks for bringing this up.

    Cheers,

    Steef-Jan Wiggers

    MVP & MCTS BizTalk Server 2010

    http://soa-thoughts.blogspot.com/ | @SteefJan

    If this answers your question please mark it accordingly


    BizTalk

    Friday, March 16, 2012 3:34 PM
    Moderator
  • The Visual Studio compiler creates *.cs files for BizTalk Schemas when building a BizTalk Visual Studio project.  However, these files should *never* be checked into Source Control and that is the cause of this problem.

    It's easy to make this mistake though.  There are two ways to add a Visual Studio Solution (containing BizTalk projects) to TFS: either by the 'Add Solution to Source Control' command within the Solution Explorer OR by the 'Add Items to Folder' command within the Source Control Explorer.  Care must be taken when using the command in the Source Control Explorer, that is, you need to exclude the *.cs files from the BizTalk Projects.  The command is not equipped with a rule which says "If the project is a BizTalk Server project (*.btproj), then exclude all the *.cs files."  So watch out.  When you use the 'Add Solution to Source Control' command within the Solution Explorer, you don't get this problem; the command does seem to be sensitive to hidden files within BizTalk projects and excludes them.

    Delete the *.cs files from your BizTalk Projects within Source Control, check-in the deletion and you should be good to go.


    • Edited by DSHester Wednesday, April 11, 2012 6:03 PM
    Wednesday, April 11, 2012 6:02 PM
  • All you have to do is delete all xsd.cs files in your directory and do a Build.  All of your supporting .cs files will be regenerated. 

    It is a good practice to get into. 

    Especially if you start seeing things like the targetnamespace is missing when you deploy.  Or any other BTS weirdness when it comes to your schemas.

    This is the easiest and fastest way.  It is weird that there were so many different thoughts on this very basic issue.

    The AwombaTomba...Zappa

    Wednesday, October 31, 2012 6:13 PM