function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RussYoungRussYoung 

Enterprise WSDL .Net Unable to generate a temporary class (result=1)

Greetings...

I have had great success in using .net and the associated API Enterprise generated WSDL and Web Reference for about a year.  I've also used the API in the Sandbox.  I hadn't made a change to the Sandbox or the Production for a couple of months.  Today I did the following in Firefox (I have had more success generating and downloading the WSDL in Firefox)

- Went to Settings/Develop/API/Generate Enterprise WSDL and clicked the GENERATE button to the right of "Generate Enterprise WSDL"
- The result in Firefox was not the normal formatted XML that I had seen in the past (perhaps the update to Firefox did this) What appeared was what looked like one big paragraph of sentences (no xml tags)
-  I right clicked in the white area of the page and "saved as"  test.wsdl
- When I opened test.wsdl, it looked like it alwas does...properly formed XML

Next in VS, I changed the Web Reference property to the Test.wsdl file name and Updated my Web Reference

======================================
Now the issue (finaly)
======================================

When I try to create an instance of SforceService like the code below:

                    SforceService sfService = new SforceService();

I get the following exception:

2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.Name InvalidOperationException
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.Message Unable to generate a temporary class (result=1).
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.Message error CS0030: Cannot convert type 'Mozenda.Business.Salesforce.ListViewRecordColumn[]' to 'Mozenda.Business.Salesforce.ListViewRecordColumn'
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.Message error CS0030: Cannot convert type 'Mozenda.Business.Salesforce.ListViewRecordColumn[]' to 'Mozenda.Business.Salesforce.ListViewRecordColumn'
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.Message error CS0029: Cannot implicitly convert type 'Mozenda.Business.Salesforce.ListViewRecordColumn' to 'Mozenda.Business.Salesforce.ListViewRecordColumn[]'
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.Message error CS0029: Cannot implicitly convert type 'Mozenda.Business.Salesforce.ListViewRecordColumn' to 'Mozenda.Business.Salesforce.ListViewRecordColumn[]'
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.Source System.Xml
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace    at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace    at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace    at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace    at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace    at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace    at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace    at Mozenda.Business.Salesforce.SforceService..ctor()
2014-09-11 16:35:30.000  Warning SalesforceClient.Connect Exception.Exception.StackTrace    at Mozenda.Business.SalesforceClient.SalesForceClient.Connect()


There is alot if information about "Unable to generate a temporary class (result=1)" doing a Google search, but nothing seems to apply.

- Has Salesforce changed how the Enterprise WSDL is created?

Thanks in advance!!

Russ






RussYoungRussYoung
Here is the answer:

First, here is the link to the article that led to the workaround:  https://connect.microsoft.com/VisualStudio/feedback/details/471297

I
 loaded the Reference.cs file that was created by Updating the Web Reference in Visual Studio into Notepad++ and did a search for adjacent double square brackes    [][] 

There were 2 lines that had the double square brackets side-by-side.  I removed one of the sets, saved the .cs file and now the .net code works.

I then went into the wsdl that was generated by Salesforce and inserted a "phony" line and then updated the Web Reference in VS.  The generated reference.cs file no longer had the double square brackets.


User-added image
Saam AbbasSaam Abbas
Thanks RussYoung! it is working perfectly after adding the given line in WSDL mentioned by you:
<xsd:attribute name="tmp" type="xsd:string" />

 Actually this problem is started in API Version 32.
BethNBethN
It worked for me too.

Salesforce,
Would it be possible to update the Enterprise WSDL to avoid this error in the future? Lots of devs use .NET and this is problematic to remember to edit the Enterprise WSDL every time we need to regenerate it.

Thanks in advance!
Aarti IyerAarti Iyer
Worked for me as well. Thank you!
LBSLBS
Works well, Kudos to you. Anyway dont we have a proper solution proposed by Salesforce yet?
sandhubalssandhubals
Worked for me as well, thanks!
Jason LushJason Lush
This worked for me as well thank you very much for posting
Kailas ErandeKailas Erande
Thanks. Gr8 help. :)
Joe VagoJoe Vago
Trying to get this working in a VB.NET project.  The Reference.vb file does not show any brackets (b/c of VB vs. C#).  Could anyone provide details on where in the double brackets issue may be seen?

PS: Russ's link does not work for me (I do have a VS online account)

Thanks in advance for any help you can provide.
Customer CareCustomer Care
Joe Vago any luck with that vb fix...I have the same issue?
 
Brian RobinsonBrian Robinson
For VB. Check the Reference.vb file for ()().

Two lots of start and end brackets, which is the equivalent of [] in c#

Cheers
Brian
 
Joe VagoJoe Vago
So I found my solution but I am slightly embarassed to admit it.  

I was highlight/copy/pasting the XML into a text editor and saving.  This caused issues in the XML WSDL (yet I am sure I did a full highlight & copy)

But selecting File -> Save Page As  saved the file correctly

FYI - You still need to add the xml string to the Enterprise.WSDL.XML file as explained above by Russ Young:
<xsd:attribute name="tmp" type="xsd:string" />
In this section of Enterprise.WSDL.XML.  Search on name="ListViewRecord" to easily find the section:
<complexType name="ListViewRecord">
      <sequence>
          <element name="columns" type="tns:ListViewRecordColumn" maxOccurs="unbounded"/>
      </sequence>
    <xsd:attribute name="tmp" type="xsd:string" />
  </complexType>
Enjoy
Pruthvi KrishnaPruthvi Krishna
Thanks Guys. This helped a lot
SalesForce API 18SalesForce API 18
So is there no way to generate the wsdl without having to modify it? Does it always require the extra xsd line mentioned above to prevent the double brackets?
RussYoungRussYoung

So is there no way to generate the wsdl without having to modify it?  Not that I'm aware of.  
Does it always require the extra xsd line mentioned above to prevent the double brackets? Yes
SalesForce API 18SalesForce API 18
This is a bug then. Where can we submit bug to the SF folks?
Chad SaarChad Saar
This is a confusing post. Mostly because the link to the solution does not work, so I can't see what your all talking about. I downloaded a WSDL for one account and it worked perfect. I just downloaded a WSDL for another account and it throws this error. Is the problem due to the XML file being opened in a text editor? Is there details on how to fix this?
mp3tobimp3tobi
Well, where can we submit this BUG to SFDC? I would like to submit this to them, but I don't know there. :)
John AlwanJohn Alwan
Editing the References.cs and removing the second set of brackets worked for me.  Thanks for this.
Joe VagoJoe Vago
All - my web searches revealed that this is supposed to be a .NET issue (unconfirmed).in dealing with what is Salesforce believes is a correctly created/formatted WSDL file.

So Salesforce says they cannot fix the issue with .NET.  I tried finding the bug report that noted this but couldn't find it again... if someone does please post a link here.
Chad SaarChad Saar
You can simply swap out an older WSDL file with a newer WSDL file and reproduce the problem without changing anything in your development environment. If it was an issue with the Framework then it would effect all WSDL files.

Additionally Microsoft built and defines the frameworks capabilties, so developers who want to use Microsoft's framework must comply with their Framework requirements. It is not on us to resolve framework requirements.

It clearly says that the type conversion they are attempting can not be done.
SalesForce API 18SalesForce API 18
I feel like we're passing blame back and forth between Salesforce and Microsoft. Regardless of whose fault it is, we as developers shouldn't have to edit the xml file to get this to work properly. If there is an MS bug report someone PLEASE post a link to it. 
Chad SaarChad Saar
Got it, they added the ListViewRecord section above at some point last year, my older files do not contain this code. You have to update the section as mentioend above except it had some invalid characters in the original post. That is why it did not work for me. Search for the following section and add the 2nd to last line. Here is how it should look.
 
<complexType name="ListViewRecord">
      <sequence>
          <element name="columns" type="tns:ListViewRecordColumn" maxOccurs="unbounded"/>
      </sequence>
    <xsd:attribute name="tmp" type="xsd:string" />
  </complexType>

 
Chad SaarChad Saar
Also, there is no [][] characters in the XML file. Not sure where that was coming from.
Tom FanningTom Fanning
I've written a tiny .NET executable designed to drop in to a pre-build event that fixes this issue. Call it right before you generate your service classes with wsdl.exe and you should be good.

https://gist.github.com/tomfanning/cfc6cc11595fd60528ed

Enjoy.
SalesForce API 18SalesForce API 18
Finally something useful! Thanks for that Tom!
Novice2Novice2
Thank you RussYoung.
David Smith 922David Smith 922
Russ Young you da man!  Here we are one year (plus) later and the same bug still exists.  Your fix did the trick for me.  Now I will be able to get my company's SF integration developed and move on to other tasks.  I am SO glad I am not a full-time SF developer!
Mason HokeMason Hoke
Thank you so much, Russ Young.. You saved me from a major struggle :)
Rolf HerbertRolf Herbert
This is still happening..I just spent an hour trying to work out why my very first SalesForce SOAP test wasnt working...this exact issue from a WSDL generated this morning...boo sales force.

Thanks for the solution, how did you ever work that out!
Prasad BapatlaPrasad Bapatla
Hi Russ, Thanks for the solution, and just to confirm, the problem still exists with VS2015 and SalesForce Enterprise Web Services API Version 37.0
Chad JoubertChad Joubert
Thank you Russ.  This saved all lot of troubleshooting.  I confirm with Prasad that there is still an issue with the wsdl generated from SalesForce Enterprise Web Services API Version 37.0 and VS2015.
Stephen SmithyesStephen Smithyes
Thanks RussYoung - I spent an hour scratching my head with this - still an issue at version 39.0 with a WSDL created today.
Shivesh Pandey 1Shivesh Pandey 1
Thank you Russ for saving our time. There is still an issue with the latest version of Enterprise WSDL.
Lucas FreiresLucas Freires
Russ Young, thanks for the answer. It worked here.
It was necessary only to update the Reference.cs file, as you said.
 
Prasad Gayan Wickrama KaluthotagePrasad Gayan Wickrama Kaluthotage
Removing [][] on Reference.cs is worked for me
Robert PierceRobert Pierce
For those wondering WHY this is happening, the below link explains it.  Basically, it's a known issue in XmlSerializer Code Generation component: it cannot handle some cases of nested unbounded elements.
https://stackoverflow.com/questions/5595779/xmlserializer-invalidoperationexc-known-issue-converting-types
 
Hemlock HarlingHemlock Harling
Thank RussYoung, just removing one '[]' from '[][]' in the Reference.cs file worked like a charm after spending full day in troubleshooting the issue!
BlindsydeBlindsyde
Thanks! I just ran into this myself after trying to get the WSDL to work in .Net Core giving up and going to .net 4.8 - turns out this little bug is in the enterprise wsdl as well as Tooling and MetaData.

ListViewRecordColumn is affected in Enterprise WSDL
QuickActionLayoutItem and NavigationMenuItem is affected in Metadata WSDL
QuickActionLayoutItem and NavigationMenuItem is affected in Tooling WSDL
Stephen Smithyes 7Stephen Smithyes 7
This bug still persists in .Net, nearly 5 years from my last comment!  I just did a new build in a new org and got the same error on the latest version.  (...but this fix still works!  Thanks)