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

Includign AutoUpdater.NET package broke Type.GetType #185

Closed
snechaev opened this issue Sep 21, 2018 · 3 comments
Closed

Includign AutoUpdater.NET package broke Type.GetType #185

snechaev opened this issue Sep 21, 2018 · 3 comments

Comments

@snechaev
Copy link

In out code we have the operation like this
var result = Type.GetType("ArrayOfint, http://schemas.microsoft.com/2003/10/Serialization/Arrays"); (the argument is actually calculated). The expected result will be null (type not found).

But after adding AutoUpdater.NET 1.4.11.0 and referencing one of static field of AutoUpdater class, the code above throws FileLoadException instead returning null.

Full test code. Create Console application (.net 4.5) and replace Program.cs with the following snippet,

using System;
using AutoUpdaterDotNET;
namespace Crash
{
    class Program
    {
        static void Main(string[] args)
        {
            AutoUpdater.ShowSkipButton = false;//commenting this will fix the issue
            var result = Type.GetType("ArrayOfint, http://schemas.microsoft.com/2003/10/Serialization/Arrays");
        }
    }
}

I make some research and found, that if I recompile AutoUpdater.NET without Resource.Embedder package (and additionally manually remove corresponding build targets from .csproj file), and use this rebuilded package instead of nuget package, the issue stop reproducing.
So, looks like the issue is caused by the bug in the Resource.Embedder package.

My environment is Win7 (with all updates) and VS2017 (15.8.4)

@ravibpatel
Copy link
Owner

@snechaev Thanks for reporting it. I will look into this.

@ghost
Copy link

ghost commented Oct 10, 2018

My knowledge of type internals is a bit rusty, but is "ArrayOfint, http://schemas.microsoft.com/2003/10/Serialization/Arrays" valid?

Checking the Type.GetType and type names documentations I can't find any reference to schema based type loading and as far as my knowledge goes it should only be "TypeName, AssemblyName"

If it is valid, could you point me to the documentation? (personal interest)

Further if I do this in a clean console app project (the true means "throw on error"):

Type.GetType("ArrayOfint, http://schemas.microsoft.com/2003/10/Serialization/Arrays", true)

I get "System.IO.FileNotFoundException: 'Could not load file or assembly 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' or one of its dependencies. The system cannot find the file specified.'"

So I think your dynamic computation of the type name is a bit off.

Regarding the crash: It happens in resource embedder as described here and I can fix it via user input validation.

@snechaev
Copy link
Author

@marcStan, the argument is invalid type, I know. We get it from third-party code, so I actually do not know how exactly it is calculated. So, the expected result is null when calling GetType with single argument, or the exception when calling with second argument set to true.

Glad to hear that crash was fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants