C# and the .NET framework are not separate things, they overlap each other. You need the CLR to JIT and manage the execution of the code. Really not a good idea.
That said, I believe there is a product which can read in assemblies and pre-compile them to native code by bundling in its own version of the CLR. Can't remember what its called but Google around. I'd expect it to be expensive, and probably not very reliable.
OK, so scrap your code and rewrite it in C++. Oh, there's a runtime for that too. Well, depending on which version of C++ you use, you might find that the runtime for that is already installed, saving you the trouble. But, that's only IF it's already installed.
Hi, I have a small app that exposes a volatile singleton class in a class library. It is consumed by 2 applications that depend on it. Here is my intent: when I add an item to the collection in 1 program, I need the other program to see it. The other methods in this class that aren't included here are Save and Delete operations to the database that are called when I add or remove an item from the collection. My problem is that eventhough I stated the keyword volatile, the added item in the collection isn't shown in the collection in the other application.
Each viewmodel has a reference to the list it is contained in. When I want to save it, I add it to my list and the list saves it to my database.
So the way my app works:
- start app 1 that shows a list of viewmodels exposed by a "thread-safe" singleton class.
- start app 2 that adds a viewmodel to the list exposed by that same singleton class.
- list in app 1 is autmatically updated as it should be the same reference.
That last part apparantly isn't true when I test my code. Can you help me out ?
publicclass CursistDepository : ObservableCollection<CursistViewModel>, IPersonDepository<CursistViewModel>
privatestaticvolatile CursistDepository instance;
privatestaticreadonlyobject padlock = newobject();
publicstatic CursistDepository Instance
if (instance == null)
instance = new CursistDepository();
IEnumerable<ICursist> persons = Cursist.Select();
foreach (ICursist person in persons)
CursistViewModel model = new CursistViewModel(person);
After your post, I went to search on how to do it cross apdomain and came up with marshalbyrefobject. However the documentation I came across was limited. Here is what I tried: I made a wrapper class that inherits from marshalbyrefobject and has variables linking to my depository classes. That didn't really do the trick sadly. Does anyone have a reliable way to do this?
Instead of a direct communication of your applications with the database, make them communicate with a serve which in turn communicates with the database. Now the server can raise an event when data of the database were changed. Your applications can subscribe to the events of the server, and update their local data.
The point is: you need an extra application as a server (a Windows Service is likely a good way to do that). For communication between server and client, you can use e.g. .Net Remoting; keep in mind that you'll need to communicate events from the server to the client - not all types of communication allow for that.
Two applications (two processes) run in completely separate spaces, static state (including singleton classes) aren't shared between processes. You need some cross-process communication to have two processes synchronise with the same data source.
What you need is a setup with not two applications but three: two client applications which talk to a service which contains all the database access, and fires events or sends messages when it's updated. Alternatively, you need to ask the database directly for updates (which may require polling, not sure if it's possible with triggers).
Hi, Iam using VS2010, while generating RDLC report, Iam using IIf statement for calculations.
But I found a typical problem which is very different.
Because from the Code.Functions for calculation, simply it's working fine, when I give the
below command directly
But I wish to give like the below command, It's giving error "local report processing"
You wouldn't use a web service to do this. What you want to be looking at is pushing out the data using something like a WebSocket or a FlashSocket. If I were you, I would take a look at SignalR[^] (if you were doing this with Node.JS, I would recommend using Socket.IO[^] instead).
I am looking for expert advice on printing the pdf files at client machine.
I have created a sample project named ClientPrint as
public interface IActiveXPrintLib
void PrintFile(string filePath);
public class ActiveXPrintLib : IActiveXPrintLib
public void PrintFile(string filePath)
AcroPDFLib.AcroPDF AcroPdf = new AcroPDFLib.AcroPDF();
I have created the dll and register the dll using regasm command on client machine.
When a file is sent to print in printer++ (a open source virtual printer, developed in c#.net), I want to get the full file name with its full physical path of that file in my c# winform app. Means I want to create a copy of these file(s) that are printed by printer++.
Actually I don't need print, i need copy that image to another location using my winform app. The scenario is when a user print any image with printer++ then my app (it will be installed with printer++ on users pc) automatically get that image and keep a copy in a folder.
These Files should be images like *.png, *.gif, *.jpg etc.
how I do this. Any suggestions for doing this in C#.Net.
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to VWorker.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
Hi, I have a project that required me to integrate VLC video player into my c# program.
I managed to have the following functions play, pause, stop, load, fast forward in the program. But one function that I have no idea on how to implement is the 'Bookmark' function which means when the video is play at some point of time when I add a bookmark on the specified time, it will automatically save into a box and when I press the bookmark it will bring me back to the time where I have bookmark on it.
Please advise if someone has done this before. Thanks in advance.
public Something() : this("default", -1)
public Something(string name): this(name, -1)
public Something(string name, index)
myName = name;
// rest of class definition
As the three constructors are doing the same thing, with the first two providing default values, simply adding the logic into the final constructor makes things simpler. This example is no longer violating the DRY principle (Don't Repeat Yourself).
I have no clue why a default constructor would call the more complex constructor.
Surprisingly, this is common and reasonable.
This is to accomplish providing default values for the various parameters of the complex constructor.
See section "10.11.6 Optional instance constructor parameters" of the : C# Language Specification[^]
Starting with C# 4.0 optional arguments (see C# Language Features, From C# 2.0 to 4.0[^]) provides this capability if the default values are constant value expressions (or new S() or default(S) where S is a value type):
See section "10.6.1 Method parameters" of the C# Language Specification (linked above).
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
There is no functional difference between these two, it's a matter of style. I normally prefer the first option (calling the more complex constructor with default arguments) because that way all the initialisation is in one place and it's easy to confirm that you have set everything you meant to.
Hi every1. This is my first post so be gentle
I want to make ,a song organizer connected with database(sql).
So basicaly windows app with option for just inserting my favorite song names with artist/genre selection thats it..
Any similar tutorial step by step or so? Im new into c# but don't know how to start.. Help plz
I am working on Windows Forms Application project (it is assignment). End this is how form should look: http://postimg.org/image/ywkeyuc5f/[^]
I need to write method that when I click on Add button textboxes should be erased (so the new value which user add could be accepted).
..the buttons, the textboxes, the labels; all the stuff on the form. What UI are you targetting? WPF, WinForms, or ASP.NET?WinForms, as stated in the original post!
Your form is a container that contains a collection of different controls[^]. There's some textboxes and some buttons on your form.
If you loop over that collection (foreach), then you can inspect all the elements on a form. You can also ask a control whether it is of a specific type. If it is of the TextBox type, then cast it to one and change it's value.
If any of above three lines sound weird then we'll expand on them
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
There are many ways you could accomplish this, ranging from the extremely simple through to just the simple. If you're just looking to set those three TextBox controls to be empty, then the quickest way is just to explicitly set the Text property to string.Empty for each one. So, suppose you had txtForename, txtSurname and txtAge as the three TextBoxes, simply do this in the event handler for the add button:
Now, you could accomplish this by looping through all the controls on the form, and loop through all the child controls as well, looking for TextBoxes, but I would stick with the simple version if I were you. Fancier implementations really are a case of YAGNI for your assignment.