Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to make a console program in C# that is independent from using System or any other libraries, that includes Console.WriteLine();. I'm making an SDK written in C# (almost like what Unity 3D does). However I don't know how to make a custom text printer. I've found no articles on the web or Stackoverflow questions related to what I want to do. There has to be someway of doing this, or Console.WriteLine(); wouldn't exist.
Here is my code so far, but I don't know how much it will help:
public static class GPrint
{
public static void Print(string str)
{
}
}
I've explored almost all of the obvious stuff like string.something() and str.something(), but there seems to be nothing related to printing a string on the screen.
Is there any way I can make a simple Console.WriteLine() clone without using the provided System namespace?
Thanks in advance!
System.Console, an abstraction over stdin/stdout is so inherent to processes that the .NET team decided to incorporate it into the common object runtime library (mscorlib).
In other words, letting a process receive input and emit output over the standard streams is so ingrained into the runtime and the base class library, that it it not possible, or at least not feasible, to have one without the other.
It's not like you can run a .NET console application omit loading the .NET Framework altogether, just because you're not using System.Console or any other class from the System namespace.
See also Hans' answer in Is mscorlib.dll/mscoree.dll loaded when .NET application runs:
Technically it is possible to not get mscorlib.dll loaded [...] Practically that only works if you provide a substitute
If you're not looking to omit mscorlib altogether, but really just are curious about writing to the console without using System.Console, see MSDN: Console Functions. You'll have to use Platform Invoke. This will come at a price though: your application will then only run on Windows, unless the platform you're running on substitutes the relevant DLLs.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to use a .NET class library written in C# in the 4GL Progress OpenEdge but I did not find good, working example. Progress says it's possible to do what I want to do, but it doesn't work.
Depending on version of Progress it might be possible to call the .Net class natively in the 4GL. However there are some limits to this. Progress for instance is very single threaded and cannot handle multi threaded .Net classes (for instance if an event occurs in a second thread). Basic support was added somewhere around 10.2B but has later been increased.
You can look at these (large) documents:
GUI for .NET Primer
GUI for .NET Programming
They are mostly about GUI programming but can be used as a reference.
The first thing you need to do is set up an assemblies.xml-file to add your component/class to your environment. After that it depends on your specific class but basic OOPABL is "quite" straightforward.
DEFINE VARIABLE c AS CLASS System.Collections.ArrayList.
c = NEW System.Collections.ArrayList().
The progress knowledgebase states:
It is possible to call .Net assemblies (DLLs) from the 4GL by using
COM (ActiveX) wrappers between the 4GL and the .Net assemblies. It is
your responsibility to write the COM (ActiveX) wrapper program. Help
in implementing this is outside of the scope of Technical Support and
we strongly recommend that you utilize the resources Microsoft has
available (msdn.microsoft.com) to help you.
This article might help: Calling a .NET Component from a COM Component
Good luck!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What are the possible ways to convert a windows form application (c# , .net) to a cross platform project?
My GOAL is have a project that can run in both Linux base os and windows.
I really like .net but it's not compatible with all OS (for example Linux) because of .Net Framework installation.
what is your suggestions?
As #paqogomez pointed out, IronPython does not take away the need for some sort of .net since, as it's stated on the website http://ironpython.net/ : "IronPython is an excellent addition to the .NET Framework, providing Python developers with the power of the .NET framework."
Since your goal is to run your existing winforms-c#-application on both, windows and linux, you might get away by just using mono (http://www.mono-project.com/).
If this doesn't work out (please refer to http://mono-project.com/Compatibility for compatability issues), you could manually rewrite your existing C# application in pure python. But then, it might well be possible to use any other unmanaged, managed or scripted language which can be used on both systems and which is either easier to translate manually or for which even automated translators exist (however, I don't know if there are any for C#).
Thinking about the last point, I did a quick websearch for "c# cross compiler" which shows some esoteric results which might be interesting for you depending on your project type.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'd like to know how to inject a C# DLL into a Unity process. Since Unity hosts a CLR (as it runs mono MSIL), I'd imagine I could play around with reflection.
So how would I inject a .NET DLL into a .Net process, and what can I do in terms of reflection once I'm in there?
For example. Say i have a game that uses unity3d as the engine, with most of the code writtin in C# (that doesn't matter since unity seems to compile unityscript to .net anyway). I want to extend this already written codebase with my own code.
Typically in a normal native process you would start reversing the code, finding pointers and data structures as they appear in memory, gaining an understanding of the code as you go along. Then writing the same structures in your code, obtain rwx access to that processes memory (typically by injecting a dll into that process) and then going to town.
Since unity uses .net however, i was wondering if there was a better way. I'd like to leverage the reflection capabilities of the .net framework. For this I think I'd need to get my code injected into the unity process. From there i don't know how a workflow might be.
Long story short: I'd like to inject a DLL, with a payload written in C# (hopefully using reflection instead of pointers), into a foreign process (i don't have control over it at compile time), and mess around with the processes internal classes and functions.
One option is the .cctor function (module initializer), which does NOT run on assembly load, but rather the first invocation into your dll.
Previously, I thought this was the earliest you could get with .net, but apparently I'm mistaken:
There's a horrible, nasty hack that lets you run a DllMain in .net - C# equivalent of DllMain in C (WinAPI)
This is certainly not something that was intended by the creators of .net. Be careful when using it.
This gets your code running, and once in, you can invoke System.Reflection like normal and do whatever you want.
Drop the DLL into an asset folder
Assets/Libs/MyLib.dll
Open any CS file and in the MonoDevelop solution add the reference.
When you quit MonoDevelop Unity will refetch the solution file and import the dll's reference.
You can now use your library from Unity code that you write in MonoDevelop just as normal.
There will be no difference between your code and any other API like System.IO.
Pay attention to the .NET framework versions, don't mix code.
To be safe, use .NET 2.0. ...wait... I don't remember but it should be 2.0... don't quote me on that.
Once you're there you can do everything as normal.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm supposed to work with Open CV, which can be programmed in C++ and deploy it in a .NET graphic interface application. I'd really like to work with C # for the interface traits.
What's the best approach for this?
I know of two ways that C# and C++ can be used in the same application.
The simplest way works where the components to be written in C++ and C# can be separated such that one component relies on the other, but they are not mutually dependent. In this case just create two assemblies, one in C# and one in VC++, and reference one from the other. This is the simplest way to do it, not least because it is supported in the UI of Visual Studio.
However, that approach will not work if there is a mutual dependency, ie, class A needs to know about class B and class B needs to know about class A, where class A is to be written in C++ and class B is to be written in C#. It is still possible to write the classes in different languages like that, using a lesser known feature of .NET called multi-file assemblies, or netmodules.
See How to: Build a Multifile Assembly and Multifile Assemblies for instructions. It is useful to remember that the C++ compiler is generally more clever than the others. I seem to remember the procedure was to get C# to compile its half to a NetModule, then pass that to the C++ compiler and linker which was capable of linking it to the C++ parts and creating the final assembly.
An alternative approach, if you only intend to write a small amount of C# code, would be to learn the VC++ syntax for the .NET features you want to use and avoid C# altogether. VC++ can declare managed interfaces and types just like C# can, and if you will not be writing much actual code in C# then this might be easier.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How can I make an interface for console applications to make them look like edit.com under Microsoft's operating systems. Target languages are C, C++ and C#.NET.
Have a look at curses:
e.g.:
http://sourceforge.net/projects/curses-sharp/
That would be based on a very simple framework which writes directly to the video to draw the underlying shadows, drop down menus, etc, not alone that, since 'Edit.com` would be written in assembler for speed in relation to drawing, this is quite ancient by today's standards, you can however take a look at PDCurses which will enable you to do this kind of thing.
The neat beauty is, PDCurses is compatible with the unix equivalent of Curses.
But, really, today, it is all about GUI and Windows....
What kind of application are you trying to do?
IIRC, from my old days, there was an object orientated framework for this using TurboVision, which has a port available with open source now, see this wikipedia entry on this TurboVision.
Today, console applications are either old DOS applications emulated more and less in Windows, or command-line interpreters.
Anyway, if you really want to do an editor, use the System.Console class in the System NameSpace and use the SetCursorPosition method to write what you want where you want
The edit.com window you are showing appear to be developed with Turbo Vision, an old console gui library written by Borland many years ago.
Borland put the software in public domain and release its C++ sources. There is also a porting to Pascal, developed by the community, called Free Vision.
Unfortunately ,I don't think there is a porting or a wrapper to dot.net, so you have to write your own. Or, at least, you can look at the sources to get inspired...