2

I have an assembly that i want to explore using c# interactive. The assembly has dependencies to other assemblies and assembly redirection is used in a config file. The other assemblies use data from the current appdomain to set thing up. Now this assembly works fine when used in a different context (i.e. not c# repl).

How can i emulate the same context in c# repl?

one of the errors i get is FileLoadException because i guess it doesnt find the correct version of some assembly.

What I have tried:

  1. override AppDomain.CurrentDomain properties by using AppDomain.SetData. config file, appbase, and other.

  2. in my csx file, reference all assemblies.

  3. copy all assemblies into C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies

Is there information on how to work with c# interactive for this kind of scenario? The only info i get when i search for it is simple tutorials. Is this even possible?

Mr Balanikas
  • 1,657
  • 15
  • 28
  • I haven't used c# interactive, but I guess that you need to put the dlls into a folder where .NET will look for it. I think that `c:\windows\system32` is one of the places where it will always look. You can test it by copying your dll to it. You can also read this question and try their answers (which are a bit old) http://stackoverflow.com/questions/1594214/c-custom-assembly-directory. You can also debug and read the Environment.CurrentDirectory in your application to see in what folder it is running and put the dlls into that folder. – mortb Jan 26 '16 at 15:49
  • Type `#r fullpath` to reference DLLs. Normal CLR search rules are in effect for dependencies so you may have to reference them first. – Hans Passant Jan 26 '16 at 16:01
  • @HansPassant I already use full paths – Mr Balanikas Jan 26 '16 at 16:03
  • 1
    Well, that doesn't help us help you, give a *concrete* example on a library that is commonly used. One that we can repro. – Hans Passant Jan 26 '16 at 16:05
  • @HansPassant in my case all libraries are proprietary, there is no common library. So I cannot give an example. – Mr Balanikas Jan 26 '16 at 16:19
  • Enable Fusion logging and it will tell you what specifically is not being loaded and why. (FusLogVwr.exe in a path like `C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools`. run it as administrator and change the capture settings) – StingyJack Mar 02 '18 at 14:14

1 Answers1

0
  1. Open developer console in Visual Studio. (CTRL + Q > Developer Console > Enter)
  2. Into App.Config file directory. (cd C:\repos\PATH_YOUR_PROJECT)
  3. Write CSI and press ENTER. (now in c# interactive console)
  4. Register using libraries with #r "C:\repos\PATH_YOUR_PROJECT\bin\Debug\MY_PROJECT.DLL"
  5. And write your code and run...

Good lock...

engin
  • 39
  • 5