CubeCoders / ConfuserEx-Reborn

An open-source, free protector for .NET applications
https://cubecoders.github.io/ConfuserEx-Reborn/
Other
94 stars 11 forks source link

Commit ccfa393 yields Error #11

Open codingdave opened 7 years ago

codingdave commented 7 years ago

Please revert the commit ccfa393 as it constitutes a regression for my WPF+Winforms project.

The issue I get on the command line is:

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Confuser.Core.ConfuserEngine.PrintEnvironmentInfo(ConfuserContext context)
   at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token)
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Confuser.CLI.Program.RunProject(ConfuserParameters parameters)
   at Confuser.CLI.Program.Main(String[] args)

The real issue is:

System.NullReferenceException was unhandled by user code HResult=-2147467261 Message=Object reference not set to an instance of an object. Source=Confuser.Core StackTrace: at Confuser.Core.ConfuserEngine.PrintEnvironmentInfo(ConfuserContext context) in D:\Projects\ConfuserEx.git\Confuser.Core\ConfuserEngine.cs:line 527 at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in D:\Projects\ConfuserEx.git\Confuser.Core\ConfuserEngine.cs:line 180 at Confuser.Core.ConfuserEngine.<>c__DisplayClass3.<Run>b__2() in D:\Projects\ConfuserEx.git\Confuser.Core\ConfuserEngine.cs:line 68 at System.Threading.Tasks.Task.Execute() InnerException:

codingdave commented 7 years ago

The cause of the trouble is when you have a WPF Application but no local namespace. Then the baml code only contains the header M S B A M L  ÿÿÿÿ WpfApplication1 WpfApplication1.MainWindow whereas when you have included the namespace you get M S B A M L  ÿÿÿÿJ FWpfApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null1clr-namespace:WpfApplication1WpfApplication1 5  WpfApplication1.MainWindow You see that Version, culture and Public Key Token are missing here. I have added a minimal sample. WpfApplication1.zip

codingdave commented 7 years ago

So instead of reverting the commit above it would be better to fix proper detection of code that does not have a local namespace. Unfortunately I have no clue how to fix that.