Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly compiled code cannot be loaded into revit #47

Open
hbbliyong opened this issue Apr 7, 2023 · 14 comments
Open

Newly compiled code cannot be loaded into revit #47

hbbliyong opened this issue Apr 7, 2023 · 14 comments
Labels
enhancement New feature or request help wanted Extra attention is needed need more info

Comments

@hbbliyong
Copy link

hbbliyong commented Apr 7, 2023

I used the latest version 1.44, the first load ran without problems, modified the code and re-run, the newly compiled code did not load into revit. Asked other colleagues, colleagues second run will prompt whether to copy the dll, mine did not. I need to close revit and re-open it to get the new code to load into revit. My environment is Windows 10, Revit 2021.
Origin :
我使用了最新1.44版本,第一次加载运行没有问题,修改代码后重新运行,新编译的代码并没有加载到revit。询问别的同事,同事二次运行会提示是否拷贝dll,我的没有。
这时候,我需要将revit关闭后重新打开,新的代码才会加载到revit。我用的环境是win10+revit2021

@chuongmep
Copy link
Owner

Hi @hbbliyong, many thanks for your reported, can give me provide some example to can create problem ?

@chuongmep chuongmep added help wanted Extra attention is needed need more info labels Apr 10, 2023
@hbbliyong
Copy link
Author

thank you for your reply.I don't know how to provide the example.i clone the code and debugged it. the code copy my dlls to the temp directory.
image
but,my dll's new code not work.
I suspect that the old code is not being replaced in revit, it is possible that static data is used in my dll.
they only work in the revit2018, the other revit version not work at all .
i'm sorry my english not very well。
i hope your can understand my mean.

@hbbliyong
Copy link
Author

hbbliyong commented Apr 11, 2023

I decompiled the dll from the temp directory, it's new, but it didn't work.
when i close the revit2021,rerun the command ,it work well.

My solution contains two projects, command and business logic code.

i alse test the test project ,i modified the test code and complied it, it can work well.

@hbbliyong
Copy link
Author

hbbliyong commented Apr 11, 2023

i found the reason. I have three dlls, the Command.dll,A.dll,B.dll.
Commond.dll refere to A.dll.
A.dll refer to B.dll.
I modified the B.dll.
I analyzed the dll referenced by revit and found that B.dll was not updated.
Maybe we should unload the B.dll.
What should we do.
IIf I modify directly the command code ,it ok.
@chuongmep

@hbbliyong
Copy link
Author

hbbliyong commented Apr 11, 2023

image
`
AppDomain currentDomain = AppDomain.CurrentDomain;
//Provide the current application domain evidence for the assembly.
Evidence asEvidence = currentDomain.Evidence;
//Make an array for the list of assemblies.
Assembly[] assems = currentDomain.GetAssemblies();

            //List the assemblies in the current application domain.
            Console.WriteLine("List of assemblies loaded in current appdomain:");
            foreach (Assembly assem in assems)
            {
                if(assem.GetName().Name.Contains("MCREV_Features1"))
                System.IO.File.AppendAllLines(@"D:\\ddd.txt", new string[] { assem.Location });
            }

`
I log all reference dll's.but only the "MCREV_Features1_Commands.dll" was update,the other dlls still old.
when you finished the command ,the first temp directory "MCREV_Features1_Commands-Executing-20230411_154218_6128" still have many dlls not be delete.

@chuongmep
Copy link
Owner

Thank for provide more information and explaination , I know that problem, Revit Addin Manager at the moment just apply for command change with one assembly, all library dependent change can't update, this also is limit of addinmanager at this time, maybe I will consider find another way to allow dependent assembly work with like same namespace so far :

  • NameSpace.Class.MethodCommand
  • NameSpace.Class.MethodLibrary

@chuongmep chuongmep added the enhancement New feature or request label Apr 11, 2023
@hbbliyong
Copy link
Author

hbbliyong commented Apr 12, 2023

@chuongmep thank you for replying.

Is there any possibility for us to solve this problem by AppDomain?
I don't know if this will give you some ideas.
PluginAppDemo

@chuongmep
Copy link
Owner

@hbbliyong at the moment, addin manager also working by resolve with App Domain because .Net Framework still is 4.8, I will think find another way when I have time, thanks for your ideas.

@hbbliyong
Copy link
Author

@chuongmep Do you mean that it cannot be solved under .Net Framework4.8?
Do you have any idea for me ,I try to solve it.

@chuongmep
Copy link
Owner

@hbbliyong I recommend you try to look this project https://github.com/dotnetcore/Natasha, if I have time, I also try to hack something

@hbbliyong
Copy link
Author

@chuongmep i have another question,why it works well in reivt2018?

@chuongmep
Copy link
Owner

@hbbliyong , I'm not sure about that, just look about 24 and fix for that .

@chuongmep
Copy link
Owner

Thank you @kelilife , I will take a look to that when I have time. I'm happy if any people have some pull request to clearly for it.

@chuongmep
Copy link
Owner

chuongmep commented Aug 22, 2023

@kelilife thank you for good catch. It is useful with any develop are looking to this project and continue to explore all detail of that. Appreciated !

@chuongmep chuongmep changed the title 新编译的代码无法加载到revit Newly compiled code cannot be loaded into revit Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed need more info
Projects
None yet
Development

No branches or pull requests

2 participants