|
I added my entire C# project to source control (CVS in this case) and am now realising that there are probably files in the project tree that shouldn't be checked in, since their generated locally (such as user settings, or build temp files)
Can anyone give me a list of all the files that shouldn't be in source control?
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
I always put in my cvs repository only the source files. I never put project files and debug files. This way I am able to use another IDE to keep progamming when I dont have visual studio or csharpdevelop.
You can put, source files, image files, resource files, and database file (once you use access ou dbf as database).
That is it, sorry my poor english.
Thiago - Brazil.
|
|
|
|
|
Hi!
I implement IOleCommandTarget in a .net COM server.
Here's my code. I'm trying to implement an object that can be used as a
COM object for a button in IE. I get a System.ExecutionEngineException when hitting the button (.
---------------------------------implement------------------------------------------
// Import IOleCommandTarget interface
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
public struct OLECMDTEXT
{
public uint cmdtextf;
public uint cwActual;
public uint cwBuf;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=100)]public char rgwz;
}
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public uint cmdID;
public uint cmdf;
}
// Interop definition for IOleCommandTarget.
[ComImport,
Guid("b722bccb-4e68-101b-a2bc-00aa00404770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleCommandTarget
{
void QueryStatus(ref Guid pguidCmdGroup, UInt32 cCmds,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] OLECMD[] prgCmds, ref OLECMDTEXT CmdText);
void Exec(ref Guid pguidCmdGroup, uint nCmdId, uint nCmdExecOpt, ref object pvaIn, ref object pvaOut);
}
-----------------------------------implement----------------------------------------
-----------------------------------using----------------------------------------
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[GuidAttribute("81AC67A9-1511-4104-93AC-BD8BFEC93F71")]
[ProgIdAttribute("MyDll.dll")]
public class GetURL: IObjectWithSite, IOleCommandTarget
{
protected SHDocVw.IWebBrowser2
m_pIWebBrowser2; // the browser class object
public GetURL()
{
}
public void SetSite(object pUnkSite)
{
// MessageBox.Show("SetSite");
if (m_pIWebBrowser2!=null)
Release();
if (pUnkSite==null)
return;
IServiceProvider isp = (IServiceProvider)pUnkSite;
try
{
//!!!!!получаем указатель на SHDocVw.IWebBrowser2 через IServiceProvider а не QueryInterface
Guid g1 = typeof(SHDocVw.IWebBrowserApp).GUID;
Guid g2 = typeof(SHDocVw.IWebBrowser2).GUID;
object obj;
//isp.RemoteQueryService( ref g1, ref g2, out m_pIWebBrowser2 );
isp.QueryService( ref g1, ref g2, out obj );
//получили объект и преобразуем его к SHDocVw.IWebBrowser2
m_pIWebBrowser2 = (SHDocVw.IWebBrowser2)obj;
}
catch(System.Runtime.InteropServices.COMException ex)
{
//
}
MessageBox.Show(m_pIWebBrowser2.ToString());
}
public void GetSite(ref System.Guid riid, out object ppvSite)
{
ppvSite = m_pIWebBrowser2;
try
{
//
}
catch(Exception ex)
{
MessageBox.Show(ex.Message + " GetSite");
}
}
public void QueryStatus(ref Guid pguidCmdGroup, UInt32 cCmds, OLECMD[] prgCmds, ref OLECMDTEXT CmdText)
{
MessageBox.Show ("Query status");
}
public void Exec(ref Guid pguidCmdGroup, uint nCmdId, uint nCmdExecOpt, ref object pvaIn, ref object pvaOut)
{
MessageBox.Show ("Execing");
}
}
-----------------------------------using----------------------------------------
In what a mistake? Help! Plz!!
|
|
|
|
|
I have two webforms in the same Project, and both have the lines
System.Drawing.Image.GetThumbNailImageAbort myCallback;
These two forms have the same using directives but the weird thing is, one form compiles fine, but the other barfs up the error:
The type or namespace name 'GetThumbNailImageAbort' does not exist in the class or namespace 'System.Drawing.Image' (are you missing an assembly reference?)
Is this a bug? Has anyone seen this before? Or am I just missing something?
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
Nick Seng wrote:
Is this a bug? Has anyone seen this before? Or am I just missing something?
You not only need to make sure your code uses a using statement to reference the assembly but you also have to make sure the compiler references the appropriate assembly as well. If you are using Visual Studio .NET you can simply add a reference to System.Drawing.dll, but if you are compiling using the command line compiler you will need to add it to the /reference switch.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nope, the references are correct and I am using VS.NET.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
How can I disable the Add and Remove buttons in the standard CollectionEditor? I already implemented my own Editor Class but how can I access the buttons because I don't want to create my own form which should look like the standard form. Or do I have to derive a class from CollectionForm and how could I do that? And I really want to disable the buttons and I don't want to display an error message.
Claudia
|
|
|
|
|
Hello,
I want to create a Table in my Smart Device Application which contains a few links which forwared to another form in my Smart Device Application. Has anybody an idea how i can do that?
thx
regards
patrick
|
|
|
|
|
Hi , ive been trying to figure out how ambient properties in .net work.
i know its possible to do something like this:
<br />
private Color blah;<br />
public Color Blah<br />
{<br />
get<br />
{<br />
if (blah == Color.Empty)<br />
{<br />
return this.Parent.Blah;<br />
}<br />
else<br />
{<br />
return blah;<br />
}<br />
}<br />
set<br />
{<br />
if (value == this.Parent.Blah)<br />
{<br />
blah=Color.Empty;<br />
}<br />
else<br />
{<br />
blah = value;<br />
}<br />
}<br />
}
this works fine in runtime but it doesnt behave as the color and font properties of a control in designtime since the ambient value is not treated as the default value.
(the ambient value is always bold in the prop browser and always persisted to the initialize code)
ive used reflector to see how the control class does it and i cant see anything different in their code (except for some offtopic activex compatabillity)
how can i specify a behaviour similair to the "[DefaultValue(..)]" dynamicly ???
i know its possible since the controls does it and they do not even specify the defaultvalue , so it must be some typeconverter related thing , right?
//Roger
|
|
|
|
|
I use the code below for a simple search function in a richtextbox. When I load larger files, and try to search it will always throw an out-of-memory exception. From the debugging it seems to be richTextBox.Find that is the culprit.
For an example, searching File1 that is 1800kB is no problem but File2 at 17000kB will always throw the exception. Opening File2 in, for example Notepad, and search is no problem.
Anyone knows why, is there a limitation with richTextBoxes and why can I then load the file with the Loadfile function?
Is there any workaround for it?
I also ran into another problem, with one specific file I don't get the exception when I search but instead "Failed to load resources from resource file. Please check your setup". I use the default settings and I did run the "fix application". Still it will crash with this message. Any fix for this?
try
{
RichTextBox.SelectionColor = Color.Black;
int searchEnd = RichTextBox.TextLength;
searchStart = RichTextBox.Find(searchTextBox.Text, searchStart, searchEnd, RichTextBoxFinds.MatchCase);
RichTextBox.SelectionColor = Color.Blue;
//RichTextBox.SelectionFont = Font.Bold;
RichTextBox.GetPositionFromCharIndex(searchStart);
RichTextBox.Focus();
RichTextBox.ScrollToCaret();
if ( searchStart < searchEnd ) { searchStart++; }
else { searchStart = 0; }
}
catch (Exception f)
{ MessageBox.Show("Failed to search " + searchFile + "\n" + f.ToString()); }
|
|
|
|
|
Embarrassingly enough I believe the out-of-memory was due to that I dodn't took care of when there was no hit on the search.
The failed to load resources probelm remains though.
|
|
|
|
|
If I keep looping the folloing statement with the new pen with a timer , will it cause a memory leak? I know C++ when you create with new, you have to use delete. But for .NET C# / VB.NET, does this apply? Do I need to use the Dispose statement every time I use the new statement? Please Advise.
mypen = New Pen(Color:=Color.DarkRed, Width:=1)
g = Me.CreateGraphics
g.DrawLine(mypen, 0, 235, 600, 235)
|
|
|
|
|
Most likely the Dispose or Close method closes or releases unmanaged resources which don't underlie the control of the GC.
If the component is well programmed it provides a finalizer which ensures that the unmanaged resources are freed when the call to Dispose was forgotten. As the finalization has an impact on performance it's recommended to call Dispose or Close. Both will suppress the finalization cause the unmanaged resources are already freed.
Take a look at MSDN[^].
www.troschuetz.de
|
|
|
|
|
alternatively you could do:
using (Pen mypen = new Pen(Color.DarkRed, 1))
{
g = this.CreateGraphics();
g.DrawLine(mypen, 0, 235, 600, 235);
}
|
|
|
|
|
|
How to do DataGrid full_row select?
|
|
|
|
|
It's a property of the grid, you either select full rows, or you only select the one cell.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
try this
<br />
<br />
void DataGrid1CurrentCellChanged(object sender, System.EventArgs e)<br />
{<br />
dataGrid1.Select(dataGrid1.CurrentCell.RowNumber);<br />
}<br />
<br />
|
|
|
|
|
is there a way from a aspx page i can run a program on the computer looking at the web site (the program is alread install on there computers) this is for my intranet not internet
thanks
chad
|
|
|
|
|
You need to ask this in the asp.net board. I'd hope the answer is no. The fact is that the platform that delivers your web page is irrelevant, you need to do it using something you can embed in the page, that IE can read ( for example, Javascript ).
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
I'd hope the answer is no.
Actually the answer is yes. They are typically called href executable, and obviously deal heavily with CAS and the temporary assembly cache. Chris Sells has an example of one here[^]. MSDN has information you can read about here[^].
- Nick Parker My Blog | My Articles
|
|
|
|
|
string strSQL = "SELECT USERID FROM TBUSERS WHERE USERNAME='" + username + "'";
string strDSN = "server=POS;uid=system;pwd=system;database=POS";
OdbcDataAdapter dataAdapter = new OdbcDataAdapter(strSQL, strDSN);
DataSet ds = new DataSet();
dataAdapter.Fill (ds);
DataTable table = ds.Tables[0];
foreach (DataRow row in table.Rows)
{
string pw = row[0].ToString ().TrimEnd (new char[] { ' ' });
if (String.Compare (password, pw, false) == 0)
return true;
}
return false;
|
|
|
|
|
Please tell me you don't ever intend on checking passwords using this code.
A good starting point would be to wrap it in a try catch and print up the exception that you're getting, so you can see what's going wrong.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
The first problem is that you're using string concatenation instead of parameterized queries like you're supposed to with ADO.NET. But instead of of ranting on for the thousandth time about it, read http://www.codeproject.com/script/comments/forums.asp?msg=932507&forumid=1649#xx932507xx[^]. Not only is it a HUGE security hole (especially since you're kind enough to give crackers system administrator access), but it also leads to problems like you're probably running into; of course, without the actual exception and exception message - like Christian mentioned - it's not easy to help you.
More than likely username has a quote in it. That's the first step in cracking your source and dropping your tables / stealing credits cards / impersonating identities / etc., by the way.
Another problem I see with your code - though not the problem since you said it's failing on OdbcDataAdapter.Fill - is that you never check for null . What if row[0] is null? null.ToString throws the most common NullReferenceException . So does table.Rows if ds.Tables[0] doesn't exist (not to mention a possible IndexOutOfRangeException if not results were returned by your query). Always reasonably check for null references (like checking i.ToString in int i = 0; i.ToString().Trim(); isn't necessary since you know that it will always return "0").
The biggest piece of advice out of all this is...never trust user input. Always validate and never assume to check for problems.
Using parameterized queries eliminates almost all SQL injection problems, especially when using data store-specific ADO.NET drivers like System.Data.SqlClient for SQL Server or System.Data.Oracle for Oracle systems, that support parameters anyway.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]an>
[My Articles]
|
|
|
|
|
Hello,
I'm working on a small project and I have to search ArrayList that contains simple object list. This is my object:
public class NameValue
{
private string strName;
private string strValue;
public NameValue( string sNameValuePair )
{
StringTokenizer tok = new StringTokenizer( sNameValuePair, "=" );
this.strName = tok.nextElement().Trim();
this.strValue = tok.nextElement().Trim();
}
private void splitName( StringTokenizer tok )
{
this.strName = tok.nextElement();
string temp = this.strName;
}
public string Name
{
get { return strName; }
set { strName = value; }
}
public string Value
{
get { return strValue; }
set { strValue = value; }
}
}
This is code where I call BinarySearch method:
public ArrayList AddPairToList( string sNameValuePair )
{
int nPos;
NameValue nv = new NameValue( sNameValuePair );
SortByName();
nPos = a.BinarySearch( nv, new CompareCustomDataType() );
if( nPos < 0 )
{
a.Add( nv );
}
else
{
MessageBox.Show( "The item you tried to add to the list already exist!" );
}
return GetCurrentList();
}
And this is my CompareCustomDataType class:
public class CompareCustomDataType : IComparer
{
public int Compare( object x, object y )
{
if (x == null) return -1;
if (y == null) return 1;
NameValue xNameValue = (NameValue) x;
NameValue yNameValue = (NameValue) y;
if( xNameValue.Name.CompareTo( yNameValue.Name ) > 0 )
{
return 1;
}
else if( xNameValue.Name.CompareTo( yNameValue.Name ) < 0 )
{
return -1;
}
return String.Compare( xNameValue.Value, yNameValue.Value );
}
}
However, it doesn't work properly. Actually, my list seems like this:
Australia = Canberra
Austria = Wiena
Canada = Toronto
Canada = Ottawa
...
When I try to add some pair to the list and if only unique pair already exist in the list (when I say unique pair I mean only one pair with unique name and unique value such as: Australia, Canberra) everything works fine, but when I try to add some pair to the list that already exist and if it is not unique pair (when I say "it is not unique pair" I mean I have pairs with the same name and different values such as: Canada, Toronto; Canada, Ottawa), first couple of times I get proper message "The item you tried to add to the list already exist!". After that, the object that already exist is added to the list and I have duplicate...
Would you be so kind to help me to fix this problem...
Thank you in advance,
Goran Tesic
|
|
|
|