I can’t really figure out what is going on!
Take a look:
The value :
http://localhost:58080/indexes/categoriesByName?query=CategoryName%3ABeverages&start=0&pageSize=25
And the problem is that I can’t figure out why calling this once would fail, but calling it the second time would fail. That is leaving aside the fact this looks like a pretty good url to me.
Any ideas? This is perfectly reproducible on one project, but I can’t reproduce this on another project.
Updates:
- This is System.Uri
- The issue that it fails the first time, and works the second!
- The exception is:
- This is a console application.
System.ArgumentNullException: Value cannot be null.
Parameter name: str
at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
at System.Uri.ParseConfigFile(String file, IdnScopeFromConfig& idnStateConfig, IriParsingFromConfig& iriParsingConfig)
at System.Uri.GetConfig(UriIdnScope& idnScope, Boolean& iriParsing)
at System.Uri.InitializeUriConfig()
at System.Uri.InitializeUri(ParsingError err, UriKind uriKind, UriFormatException& e)
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at Raven.Scenarios.Scenario.GetUri_WorkaroundForStrangeBug(String uriString) in C:\Work\ravendb\Raven.Scenarios\Scenario.cs:line 155
Okay, I can reproduce this now, here it how it got there:
public class Strange : MarshalByRefObject { public void WTF() { Console.WriteLine(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); new Uri("http://localhost:58080/indexes/categoriesByName?query=CategoryName%3ABeverages&start=0&pageSize=25"); } } public class Program { private static void Main() { var instanceAndUnwrap = (Strange) AppDomain.CreateDomain("test", null, new AppDomainSetup { ConfigurationFile = "" }).CreateInstanceAndUnwrap("ConsoleApplication5", "ConsoleApplication5.Strange"); instanceAndUnwrap.WTF(); } }
That took some time to figure out.
The reason that I got this issue is that I am running this code as part of a unit test, and the xUnit seems to be running my system under the following conditions.
