Bug 10489 - NullReferenceException on PolicyService when trying to create a solution
Summary: NullReferenceException on PolicyService when trying to create a solution
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: unspecified
Hardware: PC Windows
: Highest critical
Target Milestone: ---
Assignee: Mikayla Hutchinson [MSFT]
URL:
: 10495 10519 10602 ()
Depends on:
Blocks:
 
Reported: 2013-02-20 21:41 UTC by João Vitor
Modified: 2013-03-22 14:51 UTC (History)
11 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description João Vitor 2013-02-20 21:41:19 UTC
I get a NullReferenceException while trying to create a "C# Gtk 2.0" Project.


The same error occurs when I try to create a new "Android Application" or a "Console Application".

-----

System.TypeInitializationException: The type initializer for 'MonoDevelop.Projects.Policies.PolicyService' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at MonoDevelop.Projects.Policies.PolicyService..cctor()
   --- End of inner exception stack trace ---
   at MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy[T]()
   at MonoDevelop.Projects.Policies.PolicyContainer.GetDefaultPolicy[T]()
   at MonoDevelop.Projects.Policies.PolicyContainer.Get[T]()
   at MonoDevelop.Projects.DotNetProject.GetDefaultNamespace(String fileName)
   at MonoDevelop.Ide.Templates.SingleFileDescriptionTemplate.ModifyTags(SolutionItem policyParent, Project project, String language, String identifier, String fileName, Dictionary`2& tags)
   at MonoDevelop.Ide.Templates.SingleFileDescriptionTemplate.GetFileName(SolutionItem policyParent, Project project, String language, String baseDirectory, String entryName)
   at MonoDevelop.GtkCore.WidgetFileDescriptionTemplate.AddToProject(SolutionItem policyParent, Project project, String language, String directory, String name)
   at MonoDevelop.Ide.Templates.ProjectDescriptor.InitializeItem(SolutionItem policyParent, ProjectCreateInformation projectCreateInformation, String defaultLanguage, SolutionEntityItem item)


-----

About:

=== Xamarin Studio ===

Version 4.0 (build 2003)

Installation UUID: ad9a2d67-c4be-4c6c-b896-dcbe196e82db

Runtime:

	Microsoft .NET 4.0.30319.18033

	GTK 2.24.13

	GTK# (2.12.0.0)

=== Xamarin.Android ===

Version: 4.6.0 (Starter Edition)

Android SDK: C:\Users\joao\AppData\Local\Android\android-sdk

	Supported Android versions:

		2.1 (API level 7)

		2.2 (API level 8)

		2.3 (API level 10)

		3.1 (API level 12)

		4.0 (API level 14)

Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39

=== Build Information ===

Git revision: Release ID: 400002003

a8219130080af6661ccd827d3ae2589bbfe8c2bb

Build date: 2013-02-19 19:47:39Z

Xamarin addins: b7a7aff09b352c13ded8a27439fd6d2250361511

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 1 Mikayla Hutchinson [MSFT] 2013-02-20 22:38:09 UTC
*** Bug 10495 has been marked as a duplicate of this bug. ***
Comment 2 Mikayla Hutchinson [MSFT] 2013-02-20 22:39:57 UTC
The only way I can see this could happen is if Mono.Addins failed to return the Invariant policy set.
Comment 3 Felipe Leusin 2013-02-20 22:58:10 UTC
By checking the user name (João) and mine I think we`re both from Brazil. Despite my Windows being English version this may have something to do with Culture information?

Just a wild guess
Comment 4 Mikayla Hutchinson [MSFT] 2013-02-21 17:10:40 UTC
*** Bug 10519 has been marked as a duplicate of this bug. ***
Comment 6 Handel Camilo 2013-02-22 13:26:54 UTC
Hi, I'm from Brazil and I'm getting the same issue, both Windows and Mac Os. I can't open/create any solution.
Comment 7 Mikayla Hutchinson [MSFT] 2013-02-22 17:57:25 UTC
This may be related to bug 10547.
Comment 8 João Vitor 2013-02-23 07:50:36 UTC
Steps to reproduce:

1 - Open Windows Region settings
2 - Select tab Formats
3 - Change the combo Format to: "Portuguese (Brazil)"
4 - Apply

5 - Launch Xamarin Studio again and create a new solution.



A workarround on this bug is to change the format to "English (United States)".
Comment 9 Handel Camilo 2013-02-23 08:34:21 UTC
The problem is when I open Settings windows I'm getting the same issue and can't change Format!
Comment 10 João Vitor 2013-02-23 08:40:35 UTC
I'm sorry if it is not clear, but you need to change your region under Windows OS, control panel.

1 - Open Windows Control Panel
2 - Change View by to Category
3 - On the right side, under Clock, Language, and Region, select "Change date, time, or number formats"
4 - Under Formats: change your "Format" option.
Comment 11 Mikayla Hutchinson [MSFT] 2013-02-23 16:20:48 UTC
Confirmed, GetPolicySet ("Invariant") returns null when format settings are pt-br.
Comment 12 Mikayla Hutchinson [MSFT] 2013-02-23 16:24:50 UTC
The problem is that GetPolicySet (string name) checks name, not ID, and the name is translated to "Invariante".

I'm not sure why we use the format settings as the UI language, that seems like a bug too.
Comment 14 Mikayla Hutchinson [MSFT] 2013-02-23 16:42:42 UTC
Lluis, Duncan, we should probably do a hotfix for this.
Comment 15 Mikayla Hutchinson [MSFT] 2013-02-23 17:00:11 UTC
*** Bug 10602 has been marked as a duplicate of this bug. ***
Comment 16 Siegmar Gieseler 2013-02-23 21:07:58 UTC
I am also from Brazil, and changing Windows Settings to English soloved the problem.
Comment 17 Nischal 2013-02-28 06:25:00 UTC
Today we have checked this issue with following builds after changing format to "Portuguese (Brazil)". Now we are able to create project successfully.

X.S 4.0 -9b07a6655aa75ea1b870feacd2ac7c53b45d3889
Xamarin.Android 4.6.1
Microsoft .NET 4.0.30319.17929
GTK 2.24.13
GTK# (2.12.0.0)

This is the screencast for the same: http://screencast.com/t/eQF13p7s

Changing the status to Verified.
Comment 18 Ed 2013-03-21 16:22:34 UTC
Hi all! 
Where can I get this bug fixed build compiled for Windows?
(Sorry, I am noob here.) 
Thanks a lot. 

Ed.
Comment 19 Mikayla Hutchinson [MSFT] 2013-03-21 21:55:24 UTC
If you run the installer from xamarin.com, it should install Xamarin Studio 4.0.1, which has the fix.
Comment 20 Ed 2013-03-22 10:43:48 UTC
Thanks Michael! 
Unfortunetaly I can't run the installer because of some unsolved network issue. Every time I try it I got an "Error downloading from Google server. Android SDK". 
So, I went to http://docs.xamarin.com/guides/android/getting_started/installation/windows/manual_installation in Xamarin site and got the file for manual installation today here http://download.xamarin.com/studio/Windows/XamarinStudio-4.0.msi but the bug in this thread is still there.
I couldn't find any other link to XS recent builds.
I am running under workaround posted by Joao Vitor, but I would like to back my system to original regional settings if possible. 

Thanks again, 

Ed.
Comment 21 Duncan Mak 2013-03-22 13:24:20 UTC
You should be able to get an update to 4.0.3 (latest as of Mar 21) from the Xamarin Studio updater.
Comment 22 Ed 2013-03-22 13:41:45 UTC
Hi Duncan! 
Thanks for answer. 
Unfortunately the XS updater doesn't work in my network company. 
I got an "Error retrieving update information", probably some proxy or "safety" policies issues here. 
The infrastructure guys were unable to diagnose it until now. 
Any other way to download this build?
Maybe I should create an enviroment and build it for myself... 

Regards, 

Ed.
Comment 23 PJ 2013-03-22 14:23:16 UTC
Hi Ed, here's the direct link: http://download.xamarin.com/studio/Windows/XamarinStudio-4.0.3.13.msi
Comment 24 Ed 2013-03-22 14:51:57 UTC
PJ, thanks a lot! 
Now running with "Portuguese (Brazil)" without any problem. :)

Best Regards, 

Ed.