|
Hi...I'm just a newby in C# programming. really need help bout an application i'm doing. I would like to change the file extensions of certain files regarding data encryption. But what i also want to do is, how will I associate my customized files with a special icon that I would put into my project in visual studio 2005? Anybody pls. help....
kirkangel
|
|
|
|
|
You typically do this with a setup project. In Visual Studio, you can add a Setup Project to your solution. Inside the setup project, you can go into the File Association editor and setup a custom association between a file extension and your app. IIRC, you can set an icon for the association as well.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Goof around music jam with my brothers (with video)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Tnx a lot... you've been very helpfull...! God bless!
|
|
|
|
|
I created a windows form in VS2005 that uses Enterprise Library - DAAB - version Jan 2006 to access the DB in its constructor. Everything works fine; however, when I created a UserControl that attempts to store that form as a variable, the VS 2005 designer will not let me drag that UserControl onto a new form. It gives me the following error:
“Failed to create component ‘UserControl’. The error message follows: ‘System.NullReferenceException: Object reference not set to an instance of object. At Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.get_DefaultName(), at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseMapper.MapName(String name, IConfigurationSource configSource)…….”
Everything compiles successfully without errors; however, I am unable to use the UserControl on any forms. After debugging, I found that the error is caused by the line “Database db = DatabaseFactory.CreateDatabase();” This line is standard DAAB code and is supposed to work and it does works in all cases I’ve run across EXCEPT this.
Is this a bug in the DAAB, or VS Designer, or am I missing something? Any help will be appreciated! Thanks in advance!
Below is the relevant code:
public partial class SampleControl : UserControl
{
private ProductForm subForm = new ProductForm();
public SampleControl ()
{
InitializeComponent();
}
}
public partial class ProductForm : Form
{
public ProductForm()
{
InitializeComponent();
AccessDB();
}
private void AccessDB()
{
//THIS LINE CAUSES THE DESIGNER ERROR
Database db = DatabaseFactory.CreateDatabase();
}
}
Thanks for any help
|
|
|
|
|
Could be a bug in the designer. If it's not necessary to create a database instance in the ocntrol's designer, you can modify your code so it doesn't get loaded in design mode:
public ProductForm()
{
InitializeComponent();
if(!this.DesignMode)
{
AccessDB();
}
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Goof around music jam with my brothers (with video)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Hi,first you must know runtime and design time,
When you drag a control to your design panel in vs,
this is design time, in constructor you want to
initialize some thing, like Database db = DatabaseFactory.CreateDatabase(); but may be this operation need read some
information and this must be in Runtime not in designtime
so you will get an error.
You can have a try, not in VS design enviournment,
but in Run time to create your control or forms
may this help you
|
|
|
|
|
Note I also posted this on the SQL page as I think it might be a problem with that but not sure.
I have the user enter a part number, click a button, which loads the datagrid. I've been playing around with the SQL statement as I was getting duplicate rows. Now, when the grid loads there is completely bogus data from the database. Not sure what it's tied to or if it's just the first record. Does anyone know what may be causing this issue? I have included the SQL info for reference:
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
if(!Page.IsPostBack)<br />
{<br />
BindData();<br />
}<br />
}<br />
private void BindData()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
<br />
<br />
string SQLString = "SELECT p.PartNumber, pt.description, dd.DrawingNumber, dd.DrawingRevision, dd.DwgPath FROM parts p INNER JOIN PartTypes pt on pt.ID =p.PartTypeID LEFT JOIN DraftingData dd on dd.PartID = p.ID WHERE p.PartNumber = @PartID;SELECT w.weight, wt.Description AS wtDescription, p.PartNumber from weights w INNER JOIN weighttypes wt on wt.ID = w.weighttypeid INNER JOIN Parts p on w.PartID = p.ID;SELECT c.cost, p.PartNumber, ct.Description AS ctDescription from Costs c INNER JOIN Parts p ON c.PartID = p.Id INNER JOIN CostTypes ct on ct.Id = c.CostTypeID; SELECT s.SubPartID, s.Quantity, s.Sequence, p.PartNumber FROM SubParts s INNER JOIN Parts p ON s.PartID = p.Id "; <br />
<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds);<br />
ds.Tables[1].TableName = "Weights";<br />
ds.Tables[2].TableName = "Costs";<br />
ds.Tables[3].TableName = "Subparts";<br />
<br />
dgParts.DataSource = ds;<br />
dgParts.DataBind();<br />
txtPartNumberInput.Text = "";<br />
}
So either I have duplicates or bogus stuff. Does anyone see the problem? I really have tried to work this one out but get one problem or the other!
|
|
|
|
|
I confused your codes may be right but i never seen like this!!!
<br />
string strSqlQuery="SELECT * FROM Table WHERE id=@id" ;<br />
sqlConnection cnn = new sqlConnection(ConnectionString) ;<br />
sqlCommand cmd = new sqlCommand(strSqlQuery) ;<br />
cmd.Parameters.Add(new sqlParameters("@id",sqlDbType.Int,4,"id"));<br />
cmd.Parameters[0].value = textBox1.Text ;
sqlDataAdapter da = new sqlDataAdapter ;<br />
da.SelectCommand = cmd ;<br />
da.Fill(ds,"Table") ;<br />
dgParts.DataSource = ds.Tables[0].TableName ;<br />
dgParts.Refresh() ;<br />
Contact me for any problem...
|
|
|
|
|
I did a brief search herein, but found nothing.
I'd like to see how easy it would be to take advantage of MS Word's spell-check functionality to implement into a simple word processor of my own.
Has someone already done a CP article about that?
If I have to, I'll just make my own simple spell-checker, but I was hoping to be able to borrow Word's...
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Nevermind, all, I found it!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
I've just created a paint application using vs 2005 but it seems to be a problem
every time the user draws a shape on the canvas the paint event is triggered and the screen seems to blink every second ... looks very disturbing
I really don't know how to solve this probleme ..
Can anyone help me?
modified 30-Nov-21 21:01pm.
|
|
|
|
|
Go to the constructor of the control where you paint on, ie: a Form or a Panel. Add the lines:
<br />
this.SetStyle( ControlStyles.UserPaint , true );<br />
this.SetStyle( ControlStyles.AllPaintingInWmPaint , true );<br />
this.SetStyle( ControlStyles.DoubleBuffer , true );<br />
These commands make your painting automatically double buffered, wich ommits the flickering.
Greatings,
Djohnnie
|
|
|
|
|
Thanks a lot.
modified 30-Nov-21 21:01pm.
|
|
|
|
|
I have written an application and in the main method i surrounded my Application.Run( new MainForm() ); with a try catch clausule. If I run the project as debug and an exception occurs, a nice dialog appears explaining what went wrong, all data is stored to the disk and if pressed OK, the application closes. If I build a release version of this project the dialog does not appear. Instead I get the standard dialog from the .NET framework telling that there was an exception.
My question is how is it that my code only does what i want when running the debug version from the Visual Studio environment?
Thanx
Djohnnie
<br />
try<br />
{<br />
Application.Run( new MainForm() );<br />
}<br />
catch( Exception e )<br />
{<br />
ExceptionHandlingDialog ehd = new ExceptionHandlingDialog( e );<br />
ehd.ShowDialog();<br />
}<br />
|
|
|
|
|
I've had similar issues, apparently the debug runtime handles exceptions generated across threads (any gui app has a minumum of 2, gui and main) differently than the releasemode runtime. You need to move your exception handler into a method and attach it to the thread exception handler. Leave your try catch in place, you'll still need it to handle any exceptions generated by static classes. Even if your current implementation doesn't have any, since this is obscure and wierd behavior I'd cover it now and document why I had both ways in place.
Application.ThreadException += new ThreadExceptionEventHandler (FatalExceptionHandler);
|
|
|
|
|
You just became my personal superhero!
Your solution does excactly what I want, and is so simple
Thank you very much.
Greatings,
Djohnnie
|
|
|
|
|
Glad to be of help. I was in your shoes a few months ago.
|
|
|
|
|
If I create a default static constuctor.
Can I be guaranteed that this will be called the first time a static property or method is called?
Thanks,
Nick
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
It will be called the first time the class is loaded, so, basically, the answer to your question is yes.
--------
"I say no to drugs, but they don't listen."
- Marilyn Mansonques
|
|
|
|
|
thanks
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
|
He was asking "what time is it?", not "how does your watch work?"
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
How mundane!
|
|
|
|
|
Here's the situation:
I have 5 classes. Each class has various properties.
Example:
WindowLocation class ->
Contains properties for my main app's location, as well as other windows.
MenuOptions class ->
Contains properties for my menus. Show check margin, etc.. things like that.
No point listing them all but you get the idea.
I have them organized like this so I can simply type...
MenuOptions.ShowCheckMargin = mnuItemShowCheckMargin.Checked;
etc.
I have absolutely no idea how to save all the classes to 1 single XML file using Serialization (then read the file with serialization and set my properties up to value contained in the XML file). I looked at a million examples, and none of them apply to what I'm trying to do.
I can't put it all together, this is after days of on/off research.
I simply want all the classes to have their properties stored in 1 XML file.
Structured like this:
[Settings]
[WindowLocations]
[Main]
[X]0[/X]
[Y]0[/Y]
[/Main]
[Options]
[X]0[/X]
[Y]0[/Y]
[/Options]
[/WindowLocations]
[MenuOptions]
[ShowCheckMargin]true[/ShowCheckMargin]
[UseXPStyle]false[/UseXPStyle]
[/MenuOptions]
[/Settings]
(Note: Replace [] with HTML brackets...board screwed them up)
|
|
|
|
|
First of all, if you want your data to be serialize to the same file, the easiest way is to put all of your classes in the same container class (i.e. appSettingsMemory). Then it's all a matter of serializing this class to disk. You have to be aware of certain principles of serialization but a quick google search whould put enough light on your problems.
I might publish an article on this subject on my website soon so you may want to check it out at www.digitalGetto.com.
Good Luck
"color: rgba(0, 0, 255, 1)"__^ cXYPosition
{
^__b style="color: blue"__^public int</b__^ X;
^__b style="color: blue"__^public int Y;
}
^__b style="color: blue"__^public struct cWindowLocations
{
^__b style="color: blue"__^public <font style="color: teal">cXYPosition</font> Main;
^__b style="color: blue"__^public <font style="color: teal">cXYPosition</font> Options;
}
^__b style="color: blue"__^public struct cMenuOptions
{
^__b style="color: blue"__^public bool ShowCheckMargin;
^__b style="color: blue"__^public bool UseXPStyle;
}
^__b style="color: blue"__^public <font style="color: teal">cWindowLocations</font> WindowLocations;
^__b style="color: blue"__^public <font style="color: teal">cMeenuOptions</font> MenuOptions;
^__b style="color: blue"__^public appSettingsMemory()
{
^__i__^
WindowLocations.Main.X = 0;
WindowLocations.Main.Y = 0;
WindowLocations.Options.X = 0;
WindowLocations.Options.Y = 0;
MenuOptions.ShowCheckMargin = true;
MenuOptions.UseXPStyle = false;
}
}
^__b style="color: blue"__^public void DumpToFile(<font style="color: teal">appSettinsMemory</font> mem, ^__b style="color: blue"__^string FilePath)
{
^__b style="color: blue"__^try
{
^__b style="color: blue"__^using (<font style="color: teal">FileStream</font> fs = ^__b style="color: blue"__^new <font style="color: teal">FileStream</font>(FilePath, FileMode.Create))
{
<font style="color: teal">XmlSerializer</font> xs = ^__b style="color: blue"__^new <font style="color: teal">XmlSerializer</font>(^__b style="color: blue"__^typeof(<font style="color: teal">appSettingsMemory</font>));
xs.Serialize(fs, mem);
fs.Close();
}
}
^__b style="color: blue"__^catch (<font style="color: teal">Exception</font> e)
{
^__i__^
<font style="color: teal">MessageBox</font>.Show(e.Message);
}
}
^__b style="color: blue"__^public <font style="color: teal">appSettinsMemory</font> LoadFromFile(^__b style="color: blue"__^string FilePath)
{
<font style="color: teal">appSettingsMemory</font> mem = ^__b style="color: blue"__^new <font style="color: teal">appSettinsMemory</font>();
^__b style="color: blue"__^try
{
^__b style="color: blue"__^using (<font style="color: teal">FileStream</font> fs = ^__b style="color: blue"__^new <font style="color: teal">FileStream</font>(FilePath, FileMode.Open))
{
<font style="color: teal">XmlSerializer</font> xs = ^__b style="color: blue"__^new <font style="color: teal">XmlSerializer</font>(^__b style="color: blue">typeof(<font style="color: teal">appSettinsMemory</font>));
mem = (<font style="color: teal">appSettinsMemory</font>)xs.Deserialize(fs);
fs.Close();
}
}
^__b style="color: blue">catch (<font style="color: teal">Exception</font> e)
{
^__i>
}
^__b style="color: blue">return mem;
}
----
www.digitalGetto.com
-- modified at 15:33 Tuesday 20th June, 2006 (added De-serialization code and color formatting)
|
|
|
|