Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a program in visual basic and aren't sure what approach to take for the following: I have a neural network created (well options for several) but for the preprocessing I want the user to be able to specify HOW they can do it, freely, if they wish (generic options also available) by inputting c++ code.

I was thinking just a large textbox which then writes this to a file... and then reads & executes. I've found reference to doing this but don't understand how. If you could explain/know of a link to similar topic or see a better option I'd vastly appreciate it! Even if there's an easier option I'm very curious how to read a file as code.

Many thanks!
Posted
Comments
Sergey Alexandrovich Kryukov 26-Feb-13 15:55pm    
Is it C++ or C++/CLI (.NET), where it's totally possible?
—SA
lostandconfused1234 26-Feb-13 15:57pm    
.NET I hope. Using Visual studio basic
Sergey Alexandrovich Kryukov 26-Feb-13 16:01pm    
Then my answer will help you. I'll add some links...
—SA
Sergey Alexandrovich Kryukov 26-Feb-13 16:03pm    
Done. Please see my answer now.
—SA

The problem is just that you have to have the compiler (and linker) with your application, because, in case of unmanaged C++, you cannot guarantee there is a compiler in the system, forget about the problem of finding this compiler and its invocation. I don't think you really want to deal with that, unless you want to use some compiler with its source code, so you could embed it in your application.

With .NET, the story is very different, as C# and VB.NET compilers are always bound with the redistributable .NET Framework and are always available (but not C++!). Then the problem is solved via CodeDOM (and Application Domains, which is mode difficult part of the problem). If you are interested, I can give you some links.

[EDIT — after OP's clarification]

Thank you for clarification. Please see my past answers:
code generating using CodeDom[^],
Create WPF Application that uses Reloadable Plugins...[^].

Some more advanced issues are explained in my past answers:
Create WPF Application that uses Reloadable Plugins...[^],
AppDomain refuses to load an assembly[^],
Dynamically Load User Controls[^],
C# Reflection InvokeMember on existing instance[^],
Gathering types from assemblies by it's string representation[^].

—SA
 
Share this answer
 
v2
Comments
lostandconfused1234 26-Feb-13 16:05pm    
@SA yes please :) I didn't consider the fact it WILL need a compiler to run, which I hold my hands up and say yes, that was stupid not to consider! It's fascinating however and a link would be appreciated
Sergey Alexandrovich Kryukov 26-Feb-13 16:32pm    
Wait a second! If this is .NET, there is nothing stupid. A compiler is also comes at run-time, to support CodeDOM.
—SA
lostandconfused1234 26-Feb-13 16:14pm    
many thanks
Sergey Alexandrovich Kryukov 26-Feb-13 16:33pm    
You are welcome.
I hope now you can accept this answer formally (green button), will you?
—SA
One option would be to use CINT[^].

Root[^] also have several features you may find useful.

You'll have to use P/Invoke or C++/CLI to interface with CINT, but you will be able to execute C++ code directly.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Feb-13 16:34pm    
Even though OP mentioned, in respond to my question, that is "hopefully" can be .NET, it does not makes me sure, so your answer could be used, my 5.
—SA
Espen Harlinn 26-Feb-13 16:42pm    
When I started on my latest article: CIMTool for Windows Management Instrumentation - Part 3
I was hoping to express the code generator in a language independent manner. While I'm still using the CodeDom, it will now only output C#. Using the CodeDom is fairly convoluted, even the simplest things takes a lot of work. If it wasn't for the snippet classes, I would have rewritten the code to using a template engine.
Sergey Alexandrovich Kryukov 26-Feb-13 16:52pm    
I am not sure if I agree with you.

I do have couple of works with CodeDOM, and one of them is quite serious: I developed a core of a very unusual (CAS) Computer Algebra System, and one of the applications is the "symbolic calculator": the user can enter expressions in C# and VB.NET, and the system performs required symbolic calculations. No wonder, it is done with CodeDOM, and the API accessible to the user and passed to CodeDOM is quite advanced (with cunning way to represent symbolic expressions instead of numeric, without string data, of course).

So, there is a lot of problem in this work: CAS itself, Application Domains and associated IPC, even some UI problems, but — not a single problem with CodeDOM! I would say, this way the most smooth part, if you know its secrets, but those "secrets" are not secret, documentation was adequate... You see?

—SA
Espen Harlinn 26-Feb-13 17:02pm    
Yes, but getting things done in terms of the CodeDom certainly takes time ...
Using the compiler features is something different, and much more practical ;)
Sergey Alexandrovich Kryukov 26-Feb-13 17:14pm    
In my opinion, much less than anything else requiring compilation... I don't see where this time comes from. Development is pretty fast, runtime is pretty fast... Hard to agree with you... And also, all standard...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900