|
Guess this goes back to clarity as well, but your question is not asked in a very clear manner. Assuming by linked you mean they are in the same solution, maybe this will help you:
When you put several projects into a solution, you are then telling the system that they belong together. If you want to run one project then the other, you need to write a third project (maybe a console app?) that does the workflow management of the sequence of projects to run.
However, since you never even specify what type of projects you have put together or what you mean by 'linked' then my answer is just a guess.
|
|
|
|
|
wht do u mean by write a third project (maybe a console app?) is there any articles which u can link me to ? thanks
|
|
|
|
|
Hello. I am teaching myself more .NET, really love the technology.
I've created a simple desktop application. Basically, its a database frontend for an inventory management system.
The databse is simply an Access file (.mbd) which is in the same directory as the executable. In other words, my oleDbConnection objects look for the database (.mdb file) in the same directory.
You see, this application will be independantly run on different PCs (each PC is in a different branch of our shop). I want to make all the different PCs share the same database. Ofcourse, the PCs will be connected (via LAN) to a central database server (where my .mbd file will be stored).
In essence, all I want to do is make my application look for the .mbd file on the database server, instead of localdisk. However, there are some issues which I dont know how to address:
1) I guess the simplest way to achieve this is to create a shared network folder. But I dont think this solution is elegant... because it seems I have to hardcode the network path into the program (specifically, I have to hardcore the ConnectionString of the oleDbConnection object)
2) How do I keep the data synchronized? (ie, Race condition)
The naive way to do this would be simply allow the database to throw an exception, and simply make the user "try again". But I want a more robust solution.
In University, I learnt how to tackle race conditions in the same application using Semaphores, Monitors, etc. But I have no idea how to do it via networks.. since I am no longer dealing with Threads anymore.
I would sincerely appreciate if someone could guide me in the right direction. I am sure there are well-establish methodologies for achieving this... a nudge in the right direction will help. A link, a book, anything.
|
|
|
|
|
1) Get away from Access. That is a piece of crap. Use SQL Server Express which will allow you to migrate your application to a full-blown SQL Server without programming changes.
2) You access the remote database with a connection string. This specifies which server to look for the database on.
3) You get away from hard coding (somewhat) by putting the connection string in your application config file.
You may, however, make sure you are running the right version of Visual Studio to ensure you have the remote capabilities exposed to you. (Visual C# Express, for example, has a lot of functionality stripped from it.)
|
|
|
|
|
Hi,
How to create a setup in C# which should install database (Sql Express) and .NET Framework?
Plz Help
|
|
|
|
|
Have a look at NSIS[^]
All the Best
Akhil
|
|
|
|
|
Hi i created a c# project for MS Mobile 2005. I cant seem to get the screen to stop flickering. I try double buffering it but it still flickers like crazy. I created a timer that calls my tick method and refresh to call paint every 50 millisecond. Can someone please help me, im very new to C#. i can send the project to u if you need it to help. Its a simple game im trying to port from java to c#.
Please help,
Jan
|
|
|
|
|
just send the code so that v all can figure out what the exact reason is. without seeing the code its difficult to say what causes flickering even after buffering.
Vipin
|
|
|
|
|
Here the code
The Form, the timer and the onpaint
<br />
protected override void OnPaint(PaintEventArgs pea)<br />
{<br />
game.onPaint(pea.Graphics);<br />
this.Invalidate();<br />
}<br />
<br />
private void gameTimer_Tick(object sender, EventArgs e)<br />
{<br />
game.tick();<br />
this.Refresh();<br />
}<br />
I have a Game class, which is pasted below, i remove the other non-important code and pasted tick and paint only.
<br />
class Game<br />
{<br />
Bitmap bufferImage;<br />
public int tile_size;<br />
public Game(Form1 parent_)<br />
{<br />
parent = parent_;<br />
height = parent_.Height;<br />
width = parent_.Width;<br />
int zW = width / 3;<br />
int zH = height / 3;<br />
tile_size = zH>zW?zW:zH;<br />
offsetX = (width - (tile_size * 3)) / 2;<br />
offsetY = (height - (tile_size * 3)) / 2;<br />
bufferImage = new Bitmap(width, height);<br />
<br />
loadImage();<br />
startGame(ARCADE);<br />
}<br />
<br />
public void tick()<br />
{<br />
DateTime currentTime = System.DateTime.Now;<br />
TimeSpan duration = currentTime - timeTick;<br />
<br />
if (state == PLAY && gameType == ARCADE)<br />
{<br />
for (int i = 0; i < 3; i++)<br />
{<br />
bool toLevelup = true;<br />
if ((arcadeLevel[0,0] != -1 && arcadeLevel[0,1] != arcadeLevel[0,2]) ||<br />
(arcadeLevel[1,0] != -1 && arcadeLevel[1,1] != arcadeLevel[1,2]) ||<br />
(arcadeLevel[2,0] != -1 && arcadeLevel[2,1] != arcadeLevel[2,2]))<br />
{<br />
toLevelup = false;<br />
}<br />
<br />
if (toLevelup)<br />
{<br />
level++;<br />
init(ARCADE);<br />
}<br />
}<br />
}<br />
else if (state == PLAY && gameType == SURVIVAL)<br />
{<br />
duration = currentTime - timerSpeed;<br />
if (duration.TotalMilliseconds >= 60000 && spawn_time > 0)<br />
{<br />
spawn_time -= 50;<br />
timerSpeed = currentTime;<br />
level++;<br />
}<br />
}<br />
<br />
int position, character;<br />
duration = currentTime - timerGame;<br />
if (duration.TotalMilliseconds >= spawn_time)<br />
{<br />
int count = 0;<br />
bool generated = false;<br />
while (!generated && count < 10)<br />
{<br />
position = Math.Abs(random.Next() % (9));<br />
<br />
if (checkPlaceable(position))<br />
{<br />
generated = true;<br />
<br />
character = CHAR_PUTSU;<br />
addCharacter(character, position);<br />
}<br />
count++;<br />
}<br />
timerGame = currentTime;<br />
}<br />
<br />
Tile tile;<br />
for (int i = 0; i < landMap.GetLength(0); i++)<br />
for (int j = 0; j < landMap.GetLength(1); j++)<br />
{<br />
tile = landMap[i,j];<br />
if (tile.isHole && tile.character != CHAR_EMPTY)<br />
{<br />
duration = currentTime - tile.timerAnimate;<br />
if (duration.TotalMilliseconds >= ANIMATION_SPEED)<br />
{<br />
tile.charImgIdx++;<br />
tile.timerAnimate = currentTime;<br />
}<br />
}<br />
}<br />
<br />
if (life <= 0 && state == PLAY)<br />
{<br />
highscorePos = processHighscore();<br />
if (0 < highscorePos)<br />
{<br />
state = OVER;<br />
}<br />
else<br />
{<br />
state = END;<br />
}<br />
}<br />
timeTick = currentTime;<br />
DateTime currentTime2 = System.DateTime.Now;<br />
duration = currentTime2 - currentTime; <br />
}<br />
Graphics g = null;<br />
public void onPaint(System.Drawing.Graphics g_)<br />
{<br />
if(g == null)<br />
g = Graphics.FromImage(bufferImage); <br />
<br />
Tile tile;<br />
for(int i=0; i<landMap.GetLength(0); i++)<br />
for (int j = 0; j < landMap.GetLength(1); j++)<br />
{<br />
tile = landMap[i,j];<br />
if(tile.isHole == true)<br />
g.DrawImage(imgTile[1], tile.pixelX, tile.pixelY);<br />
else<br />
paintClipImage(g, imgTile[0], tile.pixelX, tile.pixelY, tile.landImgIdx * tile_size, 0, tile_size, tile_size); <br />
<br />
if (tile.character != CHAR_EMPTY && !tile.isWacked && tile.isHole)<br />
{<br />
if(tile.charImgIdx >= ANIMATION_SEQUENCE.GetLength(0))<br />
{<br />
tile.character = CHAR_EMPTY;<br />
}<br />
else<br />
{<br />
tile.repaint = true;<br />
paintClipImage(g, imgCharacters[tile.character], tile.pixelX, tile.pixelY, ANIMATION_SEQUENCE[tile.charImgIdx] * tile_size, 0, tile_size, tile_size); <br />
}<br />
}<br />
<br />
if (tile.character != CHAR_EMPTY && tile.isWacked && tile.isHole)<br />
{<br />
if (tile.charImgIdx > 1)<br />
{<br />
tile.character = CHAR_EMPTY;<br />
tile.isWacked = false;<br />
}<br />
else<br />
{<br />
tile.repaint = true;<br />
paintClipImage(g, imgCharacters[tile.character], tile.pixelX, tile.pixelY, (ANIMATION_WACKED + tile.charImgIdx) * tile_size, 0, tile_size, tile_size);<br />
if (tile.hammerIdx < HAMMER_IDX_MAX)<br />
{<br />
int spaced = CHAR_WIDTH - HAMMER_WIDTH;<br />
paintClipImage(g, imgHammer, tile.pixelX + spaced, tile.pixelY, tile.hammerIdx * HAMMER_WIDTH, 0, HAMMER_WIDTH, HAMMER_WIDTH);<br />
tile.hammerIdx++;<br />
}<br />
<br />
if ((tile.character == CHAR_MONG || tile.character == CHAR_PUTSU || tile.character == CHAR_PIPKOW) && tile.hitAble && tile.powerCycle > 0)<br />
{<br />
int powerY = tile.pixelY + (CHAR_WIDTH / 6) * tile.powerCycle;<br />
g.DrawImage(imgPow, tile.pixelX, powerY);<br />
tile.powerCycle--;<br />
}<br />
else if ((tile.character == CHAR_MOTERO || tile.character == CHAR_MONG) && !tile.hitAble && tile.powerCycle > 0)<br />
{<br />
int powerY = tile.pixelY + (CHAR_WIDTH / 6) * tile.powerCycle;<br />
g.DrawImage(imgMinusHeart, offsetX + tile.pixelX, offsetY + powerY);<br />
tile.powerCycle--;<br />
}<br />
}<br />
}<br />
}<br />
<br />
g_.DrawImage(bufferImage, 0, 0);<br />
} <br />
<br />
}<br />
Please help
Thanks,
Jan
|
|
|
|
|
Solutions:
Add this method... and it doesnt flicker anymore
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
}<br />
|
|
|
|
|
i need a connection string for excel file
thanks for help
MD_NADA
|
|
|
|
|
|
How to get information about starting new process in my c# app ?
Something like new process listener. Process would be started manualu by user.
|
|
|
|
|
Is there any packers for .NET apps such as: http://upx.sourceforge.net for win32?
Thanks
|
|
|
|
|
An installer like NSIS will have better compression results, but in this day and age, UPX isnt really useful.
|
|
|
|
|
hello,
i'm initiating an object inside a method:
private void Example ()
{
MyClass ins = new MyClass(...);
ins.AMethod();
ins.Dispose();
}
i'm wondering if the last line: ins.Dispose(); is necessary? Or C# does it automaticlly?... i mean disposing the object as soon as the method is finish.
please advise
|
|
|
|
|
xkx32 wrote: i'm wondering if the last line: ins.Dispose(); is necessary? Or C# does it automaticlly?...
To the first question - If the class has a Dispose() method then, yes, you should use it.
To the second question - If the class has a destructor (Finalizer) that calls Dispose() then, yes, it will eventually get to it. BUT, just because it will get to it eventually doesn't mean you can get all lazy about it. If a class supports Dispose() it is usually for a very good reason and its very existance suggests that you should use it.
xkx32 wrote: i mean disposing the object as soon as the method is finish
If that is where the object is naturally no longer required then that is where you should dispose of it. If you are only going to use an object within one method and it won't be stored anywhere else by the time the method completed then you may like to use the following instead
using (MyClass ins = new MyClass())
{
ins.AMethod();
} What happens here is that as soon as the code exits the scope of the using block for what ever reason (it might reach it naturally, or it might be in the process of throwing an exception) the object will be Dispose d of.
|
|
|
|
|
The Dispose method doesn't dispose of the object itself, it tells the object to dispose of the unmanaged resources that it's using.
If an object has a Dispose method, you should use it. It helps the object to free resources as soon as possible. If you don't call Dispose, you won't know when the resources will be freed.
As .NET uses garbage collection, not reference counting, the object will not be finalized immediately when there is no reference to it, but when the garbage collector does the next collection. Depending on the memory "turnover" of the program, this can be in seconds, minutes, hours... or not until the application ends.
---
b { font-weight: normal; }
|
|
|
|
|
Microsoft technicians state that you should never call Dispose and always allow the Garbage Collector to handle object management. That object exposing the IDispose method places it at the top of the list for GC to process.
|
|
|
|
|
Hi All,
I have a problem.
I want to assign the value of text control to a variable of double type.
If i do in this way
double price = Text1.Text
gives compilation error.
If I do in this way
double price = (double) Text1.Text
gives me run time error of invalidcast type.
How can I procceed in this case.
Regards
Every thing will come to you if you have faith.
|
|
|
|
|
Hello Amol Ravatale,
Every value type (i.e. int, double, char, etc.) has a Parse() function.
This functions are all static, meaning you don't need to instantiate an object of that type.
In your case, do the following:
double price = double.Parse(Text1.Text);
Best regards,
Shy.
-- modified at 11:53 Sunday 30th July, 2006
|
|
|
|
|
Double.TryParse() is what you want.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You're right... It's better that way since you can't really tell what's in the box...
|
|
|
|
|
Well, you can always catch the exception in Parse
Also, Parse is .NET 1.1, while TryParse is only .NET 2.0
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Every thing will come to you if you have faith.
|
|
|
|
|