1

I've something really annoying happening im my code.

I've built an app in Xamarin.Forms after battling for months with the framework just to find that when I'm now done, I cannot build my app in release mode to deploy it to the Store.

The app works well in debug mode, but does not build in release mode in the UWP project. I have been struggling to find a way to build my app in release mode for 5 days. but no matter which solution I see in all the forums and the stackoverflow questions I encounter, this error won't even blink.

The error which the IDE shows when I build the app in release mode is:

Internal compiler error: Specified cast is not valid.

It does not tell me anything more than that. The IDE doesn't give me any additional error message. I have struggled for days applying solutions I find to similar to this online, but nothing works.

  • I have updated IDE
  • Updated all packages
  • Deleted custom renderers on the UWP project
  • I went through every portion of code to find where I may have made a bad cast

I tried all I could find online, but nothing works.

I usually don't ask questions on forums unless it becomes critical. If I don't get any solution, I'll be forced to delete this project and waste the months of coding I did, and abandon Xamarin for ever and move to Flutter which has a better reputation when it comes to tooling.

R15
  • 13,982
  • 14
  • 97
  • 173
John Code
  • 655
  • 7
  • 24

1 Answers1

1

First of all, please don't fume so much. We understand you are frustrated, but Caps Lock just doesn't help to make us take it more seriously. Also I know Flutter is the new "cool guy in town", but it also has its set of issues. Cross-platform development is not simple and Flutter does support only two platforms, while Xamarin.Forms have a wider reach, which is bound to bring a bit more complexity.

My first suggestion would be to change the build output more verbose in Visual Studio Options, because that could uncover the actual issue here. When it comes to release mode, the problems usually come from types which are used for reflection but the compiler does not see as used and hence throws them away. Usually these errors show up at runtime however. In your case I would suggest a few following things:

  • First and foremost - try to delete bin and obj folders in your project. That might help, as they sometimes get cluttered with older libraries and create conflicts.
  • If you have been building with a source control like Git (I hope you did), I would suggest going back to some early commits and then try to build release mode there. If the project builds, jump forward to some newer commit and try again. If it does not, try an even earlier commit. The goal of this is to pinpoint when in time was the error introduced, which should significantly help you in searching where the problem comes from.
  • If you didn't use any source control - first remember to do so next time. However, this time you will have to do it "the old way". Create a new project and slowly as little code from the original project, trying to do release build at each step. Hopefully this will allow you to find the culprit code and then you will be able to fix it in the original project

You can definitely post your findings here and we will be happy to help you further - like pinpointing the actual problem in the code file once you narrow it down.

I suspect your problem is coming from auto-generated XAML, so definitely make sure to focus on the .xaml files adding them one by one.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
  • let me know if something moves :-) – Martin Zikmund Jul 16 '18 at 13:14
  • Hi, thanks for your reply. since yesterday, I've been trying what you told me to do. I deleted bin and obj, set build to be more verbose, and It stated, the error was located in : Microsoft.NetNative.targets. I Googled this but I didnt find any solution, so I did as you said and went back to my former commits, but when I go back to my former commits, I encounter the same errors which I've been encounterin up to this point, no matter how far I go back with my old git comits. I don't know what to do, I'll go back in my comits again, may I hope this will be Ok at some point – John Code Jul 16 '18 at 13:21