|
Totally a shot in the dark, but it seems like VS can't find the supporting dll's unless, as you said, you reference them.
Awful as it sounds, try putting your assemblies in the GAC. As I said though, this is a shot in the dark.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
Hunt The Wumpus
RealDevs.Net
|
|
|
|
|
I'm getting "System.OutOfMemoryException" in a block of code that has not changed in quite a while. Actually it is an instantiation of a User Control. There are a series of 4 UC's instantiated. The first one has had changes made to it. The remaining have not. If I comment out the second one, the error goes away.
The problem is that the error doesn't show up until I do the Show() on the containing form. How do I figure out what causes an error like this when
1. No changes were made to this UC
2. An error doesn't occur when instantiating the UI
3. Memory does not peak at all
4. Changing the first UC back to it's original form corrects the problem.
Thanks.
|
|
|
|
|
Commented out basically the entire UC and kept uncommenting until I found the line of code causing the error. It wasn't an OutOfMemoryException, due to the other changes the code was hit a reference to a NULL object.
There's got to be a better way to track those down...but misleading error messages don't help. Still not sure why the error reported as it did (after the other two UCs created and then upon parent form doing its Show method) because the problem does get encountered during form creation.
|
|
|
|
|
After performing calculation, a data need to be displayed. But the function SetWindowText() can only take parameter in string data type. How to convert the int and float into text form so that it can be displayed in the dialog using edit box (in MFC)?
|
|
|
|
|
TehGT wrote:
(in MFC)?
This is C# foru,. Try it in VC++ forum.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Hello Dears
In a DataGrid control , how i can get the row number that has been selected by user ?
|
|
|
|
|
DataGrid.CurrentCell.RowNumber
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Hello buddies,
We know if a table contains an autonumber column it is automatically increased each time a new record is inserted into ot.
I wana know what happens when this number reachs its maximum value, and whats the approach in this case?
Thank u so much,
- Den
|
|
|
|
|
EDden2Fly wrote:
I wana know what happens when this number reachs its maximum value, and whats the approach in this case?
Erm...this number is so big that you'd run out of disk space just to hold all the records way before you'd reach the max value, I would imagine.
If you use the decimal type with maximum precision, that's 10^38 unique identities! "bigint" is 9,223,372,036,854,775,807.
OK, if you use int (2Gb), smallint (32K), or tinyint (255), then yes, you'd have a problem.
So, what happens when you set an identity to a tinyint type and add the 256'th record?
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
Hunt The Wumpus
RealDevs.Net
|
|
|
|
|
An Exception of type SqlException is thrown with a message indicating an arithmetic overflow
Thank you so much Marc
- Den2Fly
---
"Art happens when you least expect it."
|
|
|
|
|
I use ado.net do something to mdb database. I found out the mdb database's size was been increased when it run some time.I can't confirm what it is cause.
It is my class,
using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
namespace RoadLib
{
///
/// NdnDataBase の概要の説明です。
///
public class NdnDataBase
{
protected string m_strConnectionString;
private OleDbConnection m_connection = null;
private OleDbTransaction m_transaction = null;
///
/// NdnDataBase の概要説明です
///
public NdnDataBase()
{
//
// TODO: コンストラクタ ロジックをここに追加してください。
//
m_connection = null;
}
///
/// NdnDataBase の概要説明です
///
/// <param name="strConnectionString" />
public NdnDataBase(string strConnectionString)
{
m_strConnectionString = strConnectionString;
m_connection = null;
}
///
/// DBコネクションを取得します
///
public OleDbConnection connection
{
get { return m_connection; }
}
///
/// DBトランザクションを取得します
///
public OleDbTransaction transaction
{
get { return m_transaction; }
}
///
/// データベースを開くために使用接続する
///
public string connectionString
{
get { return m_strConnectionString; }
set { m_strConnectionString = value;}
}
///
/// 指定のデータベースでセッションを開く
///
/// <returns>
public OleDbConnection DBOpen()
{
if(m_connection == null)
{
try
{
//データベース接続パラメータを取得
if (m_strConnectionString == "")
{
return null;
}
m_connection = new OleDbConnection(m_strConnectionString);
//DBオープン
m_connection.Open();
}
catch(Exception err)
{
//NdnPublicFunction.WriteLog(m_strLogFileName, err.Message);
m_connection = null;
throw (err);
}
}
return m_connection;
}
///
/// データベースでセッションを閉じる
///
/// <param name="connection" />
public void DBClose()
{
try
{
//DBクローズ
if (m_connection != null)
{
m_connection.Close();
}
}
catch
{
}
finally
{
//初期値を設定
m_transaction = null;
m_connection = null;
}
}
///
/// SQLステートメントを実行
///
/// <param name="strCommandText" />
/// <param name="connection" />
/// <param name="transaction" />
/// <returns>
public bool ExecSql(string strCommandText, OleDbConnection connection, OleDbTransaction transaction)
{
bool bReturn = false;
OleDbCommand dbCommand = new OleDbCommand(strCommandText, connection, transaction);
try
{
dbCommand.ExecuteNonQuery();
bReturn = true;
}
catch( Exception err)
{
throw (err);
}
return bReturn;
}
///
/// データベースでトランザクションを開始します
///
/// <returns>
public bool BeginTrans()
{
bool bReturn = false;
try
{
if (m_connection != null)
{
m_transaction = m_connection.BeginTransaction();
bReturn = true;
}
}
catch (Exception err)
{
throw err;
}
return bReturn;
}
///
/// データベースでトランザクションをコミットします
///
/// <returns>
public bool CommitTrans()
{
bool bReturn = false;
try
{
if (m_transaction != null)
{
m_transaction.Commit();
bReturn = true;
}
}
catch (Exception err)
{
throw err;
}
finally
{
m_transaction = null;
}
return bReturn;
}
///
/// データベースでトランザクションをロールバックします
///
/// <returns>
public bool RollbackTrans()
{
bool bReturn = false;
try
{
if (m_transaction != null)
{
m_transaction.Rollback();
bReturn = true;
}
}
catch (Exception err)
{
throw err;
}
finally
{
m_transaction = null;
}
return bReturn;
}
}
}
I use it to operate mdb database.
for example:
NdnDataBase database = new NdnDataBase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\nara.mdb;User Id=admin;Password=;");
try
{
database.DBOpen();
database.BeginTrans();
database.ExecSql("Delete from ttt");
...
database.ExecSql("Insert into ttt values(1, 2)", database.connection, database.transaction);
database.CommitTrans();
...
}
catch
{
database.RollbackTrans();
}
finally
{
database.DBClose();
}
it operation is in a timer event.
At last, the database is bad.
|
|
|
|
|
What do you mean by "the database is bad"?
Without providing a more detailed error description it's very hard to help you!
Just one thing that comes to mind: Do you disable your timer while your function is executing? If not, the cause for your problems could be the timer re-entering the function while the previous timer event is still executing...
Regards,
mav
|
|
|
|
|
You may want to try Compact and Repair Database. We have a system that has the UI and Database separated. The front end never changes but it continues to grow just from using it! Since there is no data changes being made, I know that there are "features" in .mdb files that just need routine maintenance.
|
|
|
|
|
Access doesn't reclaim disk space when deleting or altering recrods until you tell it to do a compact and repair. Also, indexing sometimes places pads so that it can be better optimized. Really, it isn't a problem if you do regular housecleaning.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
Hunt The Wumpus
RealDevs.Net
|
|
|
|
|
Dear friends!
I have a strange problem with C# and the Graphics-class.
My Form contains a pictureBox, on which a black and a red rectangle is drawn as soon as the user clicks on it. The Red Rectangle uses Color (200,255,0,0), so an Alpha value for transparency. The result can be seen here:
Link:http:\\www.bluecommerce.net\error.jpg
The code is:
Code:
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
SolidBrush pen1 = new SolidBrush(Color.FromArgb(200,255,0,0));
SolidBrush pen2 = new SolidBrush(Color.Black);
Graphics Graph = userControl1.CreateGraphics();
Graph.FillRectangle(pen2,e.X - 50,e.Y - 50,100,100);
Graph.FillRectangle(pen1,e.X - 50,e.Y - 50,100,100);
}
As you can see, the red rectangle is NOT rendered in the vincinity of the Mouse cursor (the mouse icon), you can see the black Rectangle through it. This happens ONLY if the Red Rectangle has an alhpa value which is NOT 0 or 255. 0 and 255 work of course.
This error happens only on my computer and a similar one (both have Windows 2000 and a Matrox G450 Millenium graphics card), on another computer with WinXP and another graphics card the same code works perfectly.
All current drivers and ServicePacks fpr GDI, GDI+, Windows 2000, Visual Studio .NET 1.0 (Service Pack 2) are installed.
Now, I would like to know if the error occures because of the
a.) Graphics card
b.) Windows 2000
c.) Visual Studio .NET
d.) GDI+
e.) my fault?
Who already encountered something similar and knows help?
I've already spent hours in searching at msdn and google, but did not find anything.
Thank you very much for your help.
Kind Regards
Marcel
|
|
|
|
|
Don't know if it really has something to do with the problem you're experiencing, but you could take a look at the color depth of your display.
I remember having troubles with the TransparencyKey of System.Windows.Forms.Form when used with 32bit color depth. Using 16 or 24 bpp worked fine, using 32bpp required a workaround to get transparency to work.
So if you're using 32bpp you should switch to 24bpp and test whether the problem still persists.
Regards,
mav
|
|
|
|
|
Hi mav!
Thank you very much for your help, with 24 bpp, it works!
But of course, I have to use 32 bbp. Could you explain the workaround you used?
Thank you again for your help.
Kind Regards
Marcel
|
|
|
|
|
Of course I can, but I don't know if this will help you because the workaround is used to make parts of an image completely transparent and you said you wanted other alpha values than 0 or 255...
Anyway: The usual approach to make parts of a Form transparent is to assign a BackgroundImage and set the TransparencyKey to a color in your image. This works with color depth up to 24bpp, with 32bpp it seems to fail completely (i.e. you see your mask color, no transparency at all).
The suggestion some MS guy made was to first load the image, then make it transparent using Bitmap.MakeTransparent() and then setting the TransparencyKey to what you receive from calling Bitmap.GetPixel() for a pixel position you know to hold the mask color.
In code that means (used in the Load event handler of a Form ):
System.Drawing.Bitmap Img = new System.Drawing.Bitmap("Example.bmp");
Img.MakeTransparent(Img.GetPixel(0,0));
this.BackgroundImage = Img;
this.TransparencyKey = Img.GetPixel(0,0); Unfortunately, this approach doesn't work well for 24 or 16bpp displays
Perhaps you can come up with a solution by comparing the colors before and after making the bitmap transparent...
Regards,
mav
|
|
|
|
|
I'm using windows API to draw theme text onto a control. The text draws, but does not display the white shading that it should, I get only black.
I've tried with almost all types and value flags, but nothing changes. I get either thin, normal sized black text, or shaded black text (that looks bold).
I've used the flag for greyed out text as well, but still no luck.
I'll post some source code when I get home, but I don't have any now.
Any ideas why this happens?
Cheers
Cata
|
|
|
|
|
Say if you make a program that alows the user to "save a phone number, or Save a file". How do you save then load the file in the program? And create a directory and access it for the saved items?
I just got into c# when the summer started. So Thanks.
WartHog
|
|
|
|
|
There is no standard way - this is what programs do. You must decide the saving and loading routines.
If you want to write a text file, you can use a TextWriter derivative, like StreamWriter or simply use File.CreateText . When you read it, use a TextReader or simply File.ReadText (which returns a TextReader , an abstract class for other classes like StreamReader .
If you want to write binary files, you can use FileStream to both read and write.
If you want to store these attributes (like the phone number) in an object and serialize that to XML (a text format), then use XmlSerializer defined in the System.Xml namespace.
There's really a seemingly infinite ways of accomplishing this task and it all depends on what you want to do. This is a basic concept, however. I recommend that you read the .NET Framework SDK - especially the programming topics - and pick up a book or two on developing applications with .NET. If you read the .NET Framework SDK - and you should - the class documentation for those classes I mentioned above even have examples.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
|
It seems that specific books aren't usually recommended here (always the SDK's) but I lived in the C# Unleashed book (published by Sams) for the first six months of C#. Since then, I always have it handy along with Mastering Visual C# .Net which is published by Sybex. I know, the SDKs are free, but for the clarity, the $40 each was worth it!
Between the two, you will find how to do just about everything you need to do. In your projects, you will hit very specific advanced things you want to do (like change colors in a grid) which may not be clear. Then you visit the trusty The Code Project and pull up one of the many examples.
Good luck.
|
|
|
|
|
Thanks I will keep it in mind-its sounds really useful.
-WartHog
|
|
|
|
|
As a user keys text into a combobox I am adding or removing the contents of the list and reloading as needed. The problem is that the cursor jumps to the first character.
How can I stop this from happening or reset the cursor? Is there a better way to do this?
Thanks
|
|
|
|
|