Performance Considerations When Dynamically Compiling a .cs File
I have a .cs file that I would like to share between two projects. I am not able (mostly due to business constraints) to build the .cs file into a .dll and either reference it in each project or drop it into the GAC. I am considering keeping the .cs fi开发者_如何学Cle in one project (actually in the app_code folder of a web project) and then referencing the physical .cs file from the other project (a web service project), dynamically building it, and then using the classes and methods. The .cs file contains strickly static classes and methods at this point but could contain non-static types at some later date.
My question is, do you see anything ridiculous about this plan in terms of performance? I know it may be difficult not knowing the nature of the code, but perhaps you could just speak to the general performance of the dynamic compilation and point out any bottlenecks, constraints, etc. that you might see.
Thanks.
C# compiles relatively fast. What kind of usage are you looking at in terms of:
- Number of compilers per second or minute
- Size of the code being compiled
At 500 compiles per second for a 1MB file. I'd say it's ridiculous. At 1 compile per minute for a 10kB file. It should be fine.
Don't bother optimizing before it becomes an issue.
But then, in the first place, it would be nice to be able to create a DLL. No being allowed to make a DLL is trouble enough. Want to optimize the workaround is even crazier.
Hope things work out for you.
精彩评论