Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Illegal characters in path exception #146

Closed
crisfervil opened this issue Mar 30, 2017 · 2 comments
Closed

Illegal characters in path exception #146

crisfervil opened this issue Mar 30, 2017 · 2 comments
Labels

Comments

@crisfervil
Copy link

crisfervil commented Mar 30, 2017

Trying to use Fake-Xrm-Easy inside node.js, using edge.js, and calling the method GetOrganizationService in the XrmFakedContext, I'm getting the following exception:

System.TypeInitializationException: The type initializer for 'FakeItEasy.Core.FakeScope' threw an exception. ---> System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
   at System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(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.Reflection.RuntimeAssembly.get_Location()
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
   at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
   at FakeItEasy.Core.TypeCatalogue.GetAllAssemblies(IEnumerable`1 extraAssemblyFiles)
   at FakeItEasy.Core.TypeCatalogue.Load(IEnumerable`1 extraAssemblyFiles)
   at FakeItEasy.ImportsModule.<>c__DisplayClass3.<RegisterDependencies>b__1(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.SingletonResolver`1.UnresolvedState.Resolve(DictionaryContainer container)
   at FakeItEasy.IoC.DictionaryContainer.<>c__DisplayClass1`1.<Register>b__0(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.Resolve(Type componentType)
   at FakeItEasy.ServiceLocator.Resolve[T]()
   at FakeItEasy.ImportsModule.<RegisterDependencies>b__0(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.SingletonResolver`1.UnresolvedState.Resolve(DictionaryContainer container)
   at FakeItEasy.IoC.DictionaryContainer.<>c__DisplayClass1`1.<Register>b__0(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.Resolve(Type componentType)
   at FakeItEasy.ServiceLocator.Resolve[T]()
   at FakeItEasy.ImportsModule.<RegisterEnumerableInstantiatedFromTypeCatalogue>b__5[T](DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.SingletonResolver`1.UnresolvedState.Resolve(DictionaryContainer container)
   at FakeItEasy.IoC.DictionaryContainer.<>c__DisplayClass1`1.<Register>b__0(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.Resolve(Type componentType)
   at FakeItEasy.ServiceLocator.Resolve[T]()
   at FakeItEasy.Core.FakeScope.RootScope..ctor()
   at FakeItEasy.Core.FakeScope..cctor()
   --- End of inner exception stack trace ---
   at FakeItEasy.Core.FakeScope.get_Current()
   at FakeItEasy.IoC.DictionaryContainer.<>c__DisplayClass1`1.<Register>b__0(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.Resolve(Type componentType)
   at FakeItEasy.ServiceLocator.Resolve[T]()
   at FakeItEasy.RootModule.<RegisterDependencies>b__3(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.<>c__DisplayClass1`1.<Register>b__0(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.Resolve(Type componentType)
   at FakeItEasy.ServiceLocator.Resolve[T]()
   at FakeItEasy.RootModule.<RegisterDependencies>b__1c(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.<>c__DisplayClass1`1.<Register>b__0(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.Resolve(Type componentType)
   at FakeItEasy.ServiceLocator.Resolve[T]()
   at FakeItEasy.RootModule.<RegisterDependencies>b__1b(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.<>c__DisplayClass1`1.<Register>b__0(DictionaryContainer c)
   at FakeItEasy.IoC.DictionaryContainer.Resolve(Type componentType)
   at FakeItEasy.ServiceLocator.Resolve[T]()
   at FakeItEasy.A.Fake[T]()
   at FakeXrmEasy.XrmFakedContext.GetFakedOrganizationService(XrmFakedContext context)
   at FakeXrmEasy.XrmFakedContext.GetOrganizationService()
   at Startup.<Invoke>d__0.MoveNext()

The Javascript code that I'm trying to run is the following:

var edge = require('edge');

var helloWorld = edge.func({source:function () {/*
    using System.Threading.Tasks;
    public class Startup
    {
        public async Task<object> Invoke(object input)
        {
		var x = new FakeXrmEasy.XrmFakedContext();
		
		try{
			var y = x.GetOrganizationService(); 
		}
		catch(System.Exception ex){
			System.Console.WriteLine(ex);
			throw ex;
		}
		return null;
        }
    }
*/}, 
references:[
'FakeXrmEasy.dll',
'Microsoft.Crm.Sdk.Proxy.dll',
'Microsoft.Xrm.Tooling.Connector.dll',
'Microsoft.Xrm.Sdk.dll',
'System.Runtime.Serialization.dll',
'Microsoft.IdentityModel.Clients.ActiveDirectory.dll',
'System.ServiceModel.dll',
'System.Activities.dll']});

helloWorld('JavaScript', function (error, result) {
    if (error) throw error;
    console.log(result);
});

Attached example:
FakeXrmEasyTest.zip

In order to run the example, download, unblock and unzip the attached file.

In a console, cd into the extracted dir and type

npm install

then

node test

You should see the above error message.

Any ideas about what can be causing this?

Thanks

@jordimontana82
Copy link
Owner

Hi Cris!

After banging my head on the wall for many hours.... it turns out this issue is related to the node version used by edge.

Running with node 6.x fails whereas with 0.10.33 does work.

0.10.33 is really old but should be enough for unit testing stuff. If you want to have many concurrent versions of node in your laptop, try nvm.

What I did was:

nvm install 0.10.33
nvm use 0.10.33

Reopen visual studio and rerun the test. And then it should work fine.

Will close this now but please reopen it if you still have issues! ;)

@jordimontana82
Copy link
Owner

jordimontana82 commented Jan 28, 2018

Hey Cris,

I've got this working for other Node versions (i.e. 6.4.0) by patching FakeItEasy to not search assemblies with Invalid chars in path (turns out the edge native assembly had one...)

So you can get version 3.2.0 and patch it, or you'll find the patch already built here

image

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

No branches or pull requests

2 participants