user2347300
user2347300

Reputation: 39

Add files to existing project programatically using C#

I am currently developing a solution that has two projects on it: one is some kind of API where I put all the functions that I want to use in the second.

So, at some point in the project, I need to create a file programatically. This is ok, but I need to include that file in my second project to use the functions from the first projects! Any idea on how to do this?

I have tried the EnvDTE but I think it only works if you are creating a new solution and a new project.

Really need help on this! Thanks in advance! :)

Upvotes: 0

Views: 185

Answers (1)

Tombala
Tombala

Reputation: 1690

Are you literally trying to recompile the second project after creating these files or is this all happening at runtime?

To me it sounds like what you're trying to do is really not create a file but to emit a class in memory during runtime to make new functions available to the second executable. You should check out Reflection.Emit. That is how you define classes, even assemblies, that didn't exist when you started running the program. Check out MSDN and this code project article.

Upvotes: 2

Related Questions