Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flush Assembly cache?
#1
Hello there.

I have figured out how to compile an assembly .dll file with a bunch of common class methods that I reuse often and share with my team.  That's much more efficient than trying to replicate individual class files.  However, I noticed that once I compile and use the assembly once it seems to get cached.  If I make changes to that class and re-compile the .dll file, I get runtime compile/link errors when trying to run a script referencing that .dll until I exit Autepad and re-launch the UI.

Is there a way to do something similar to flushing  module/library cache?  I'm thinking similar things happen occasionally on linux and I'd run something like a ldconfig to rebuild the shared library cache.

It's not the end of the world to exit/re-launch, but if I'm debugging something and re-compiling it's a bit of a pain.  Ideally though and in normal operation that library isn't changing very often.
#2
Should work without restarting the editor. Can you post a simple library class file and 1 or 2 scripts that could help to reproduce the problem? Menu Edit -> Forum copy.

I tested this. Works without restarting the editor.

1. Create a library project with 1 class file:
C# code:
// class "Library3.cs" /*/ role classLibrary; outputPath %folders.ThisApp%\Libraries; /*/
using System.Reflection;

[assembly: AssemblyVersion("1.0.0.0")]

namespace Library3 {
public class Class1 {
    public static void Function1() {
        print.it(1);
    }
}
}

2. Click the Compile button.
3. Create a script and add the assembly file (Properties -> Assembly...).
C# code:
// script "" /*/ r Libraries\Library3.dll; /*/

Library3.Class1.Function1();

4. Run the script. It prints 1.
5. In the class file replace 1 with 2. Compile again.
6. Again run the script. No errors. It prints 2.
#3
C# code:
/*/ role classLibrary; outputPath %folders.ThisApp%\Libraries; /*/

namespace TestNS;
/// <summary>
///    Do some stuff, nothing important 
/// /// </summary>
public static class TestLib {
    
    /// <summary>
    /// Do something
    /// 
    /// </summary>
    public static void PrintSomething() {
        print.it("Something");
    }
}

I compiled that...  Then created a script that references:

C# code:
/*/ r Libraries\TestLib.dll; /*/

using static TestNS.TestLib;

PrintSomething();


Then I went back and added another static method to the class:

C# code:
// class "TestLib.cs" /*/ role classLibrary; outputPath %folders.ThisApp%\Libraries; /*/

namespace TestNS;
/// <summary>
///    Do some stuff, nothing important 
/// /// </summary>
public static class TestLib {
    
    /// <summary>
    /// Do something
    /// 
    /// </summary>
    public static void PrintSomething() {
        print.it("Something");
    }
    
    public static void PrintSomethingElse() {
        print.it("Something Else");
    }
}

... recompiled and tried to reference in the script:

C# code:
// script "" /*/ r Libraries\TestLib.dll; /*/

using static TestNS.TestLib;

PrintSomething();
PrintSomethingElse();


Then I get the red squiggly under the PrintSomethingElse call and get a compile error stating:
Compilation: 1 errors
<open "<0x1000000AB>|6|1">Script5.cs(6,1): error CS0103: The name 'PrintSomethingElse' does not exist in the current context

Same thing seems to happen if I modify the type parameters or return type of a method...  In some cases even changing code.  Not sure what is happening there.  I can try on another machine.  It's just odd.

I was able to change some stuff inside the method and it worked... after restarting the editor, I ran the same script and got the "something else" output...

changed the print.it line to ("I dont want to"), recompiled and I got expected output.  It seems maybe more to do with adding/changing methods in a class?
#4
Now I see. Will be improved in next version. Probably this week. Thank you.
#5
Cool.  You rock!
#6
Also instead of r can be used pr (project reference). Then after changing library source code even don't need to compile it explicitly.

In scripts replace
/*/ r Libraries\Library3.dll; /*/

with
/*/ pr \@path to\TestLib.cs; /*/


Forum Jump:


Users browsing this thread: 1 Guest(s)