Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code conversion breaks within one minute with a big object reference error dialog. #804

Closed
Panchraj opened this issue Dec 28, 2021 · 7 comments
Labels
exception caught An exception is caught (and stacktrace provided) VB -> C# Specific to VB -> C# conversion

Comments

@Panchraj
Copy link

Steps to reproduce

  1. Right click on my VB.net Project named OFMEngine.
  2. it displays below info in output window.
    Building solution prior to conversion for maximum accuracy...
    Converting OFMEngine...
  3. Then it display a big dialog error having below information.

Error message shown


Code converter 8.4.3 - Visual Studio 16.11.31911.196

An error has occurred during conversion - press Ctrl+C to copy the details: System.NullReferenceException: Object reference not set to an instance of an object.
at ICSharpCode.CodeConverter.CSharp.ProjectMergedDeclarationExtensions.d__2.MoveNext()

detailed error is attached.
VB to Csharp Conversion error.txt

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Dec 28, 2021

Thanks for the report, I'll try to figure out what is null. I may need more info about the project file to verify any fix since it likely relates to a referenced resx

public static IEnumerable<(string RelativePath, string LastGenOutput)> ReadVbEmbeddedResources(this Project vbProject)
{
if (vbProject.FilePath == null || !File.Exists(vbProject.FilePath)) yield break;
var projXml = XDocument.Load(vbProject.FilePath);
var xmlNs = projXml.Root.GetDefaultNamespace();
foreach (var resx in projXml.Descendants().Where(IsStandaloneGeneratedResource)) {
string relativePath = GetIncludeOrUpdateAttribute(resx).Value;
string lastGenOutput = resx.Element(xmlNs + "LastGenOutput").Value;
yield return (relativePath, Path.Combine(Path.GetDirectoryName(relativePath), lastGenOutput));
}

@Panchraj
Copy link
Author

Project file is attached.
OFMEngine.txt

@GrahamTheCoder GrahamTheCoder added exception caught An exception is caught (and stacktrace provided) VB -> C# Specific to VB -> C# conversion labels Dec 30, 2021
@GrahamTheCoder
Copy link
Member

Thanks, I'll try to take a look soon

@Panchraj
Copy link
Author

Panchraj commented Dec 31, 2021 via email

@GrahamTheCoder
Copy link
Member

The code will go out in the next release (probably in the next week or two). In the meantime if you need the fix, you can uninstall the current extension, and install the CI build (the VSIX) from the bottom of this page: https://github.com/icsharpcode/CodeConverter/actions/runs/1640619541
Let me know if it works for you, thanks!

@Panchraj
Copy link
Author

Panchraj commented Jan 7, 2022

Now its working fine. Thanks a lot.

@GrahamTheCoder
Copy link
Member

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exception caught An exception is caught (and stacktrace provided) VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants