|
I'm having difficulty using the Visio Drawing Control 2003 and the RichTextBox anywhere in the same application.
e.g.
public partial class VisForm : Form<br />
{<br />
public VisForm()<br />
{<br />
<br />
InitializeComponent();<br />
<br />
RichTextBox rttb1 = new RichTextBox();<br />
string rtf1 = rttb1.Rtf;<br />
rttb1.SelectedRtf = @"{\rtf1\ansi " + "Visible" + @"{\v " + "Hidden" + @"}}";<br />
string rtfText1 = rttb1.Text;<br />
<br />
}<br />
<br />
---<br />
}
First Scenario:
Initialize the RichTextBox BEFORE the Visio Drawing Control. Set rttb.SelectedRtf = @"{\rtf1\ansi " + "Visible" + @"{\v " + "Hidden" + @"}}";
rttb.Text will then be "VisibleHidden" which is correct. With the form displayed press CTRL+F to display the Find Dialog. The result is an AccessViolationException with the following message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt".
Second Scenario:
Initialize the RichTextBox AFTER the Visio Drawing Control. Set rttb.SelectedRtf = @"{\rtf1\ansi " + "Visible" + @"{\v " + "Hidden" + @"}}";
rttb.Text will then be "Visible" which is WRONG. i.e. the hidden text does not get set when the Visio Control is initialized before the RichTextBox. With the form displayed, this time pressing CTRL+F results in the Find Dialog being displayed with no problem.
Any ideas?
Thanks,
B.
|
|
|
|
|
I need to use lambda expressions or other way to
specify default query for dlinq entity type.
Code below causes compile error shown in comment.
How to fix ?
Andrus.
using System;
using System.Linq;
// '<' unexpected : attributes cannot be generic
[QueryAttribute<Supplier>(d=> d.Discriminator=="Domestics")]
class DomesticsSupplier {
public string Discriminator { get; set; };
public string Name { get; set; };
}
class QueryAttribute<TEntity> : Attribute {
IQueryable<TEntity> Query;
internal QueryAttribute(IQueryable<TEntity> query) {
Query = query;
}
}
Andrus
|
|
|
|
|
You can't fix it. Attributes are used at compile time. You can not use runtime values to determine the value for an attribute.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
This *is* pure compile time expression. It does not contain ani variables.
So it can resolved.
Andrus
|
|
|
|
|
There are two problems here:
1) Attributes can not be generic.
2) Even tho your expression can be resolved at completime, you can not use it in an attribute.
attributes are really picky about what you pass to them
for example, one might thing that something like [DefaultValue(Color.Red)] might be valid, since Red seems to be pretty constant... but it is not.
(My guess would be that even tho the structure of expression tree can be resolved at compiletime, the generic types that hold them are only available at runtime and this makes it an illegal value for attributes)
So you are out of luck on this one..
|
|
|
|
|
AndrusM wrote: This *is* pure compile time expression.
No, it's not. The lambda expression evaluates into a delegate.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
>>No, it's not. The lambda expression evaluates into a delegate.
Lambda expressions can also be Expression trees, so it is not always delegates...
Expression < func < foo,bool> > exp = foo => foo.Bar > 10;
(man the CP formatting is f..ed up)
|
|
|
|
|
Roger Alsing wrote: Lambda expressions can also be Expression trees, so it is not always delegates...
Then you would have to declare the parameter to be an expression, otherwise the compiler won't make code to build the expression tree.
As an expression is a generic type, I doubt that you can use it as a parameter in an attribute.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi All,
I am trying to import a txt file into MSAccess database and later into SQL server database using C# Code.This is the whole purpose.
I have two questions.
1)I have a txt file that has double quotes as field separator.This text contains more than 44lakh lines with morethan 10 columns.I want to import this into an MSAccess database using C# code.I will be having a blank database already created for this purpose.We just have to import the data into this blank database using C# Code.Is it possible,if so how?
2)This is basically a continuation of the previous issue. The file that we imported into MSAccess has to be now imported into SQL server 2005 database using C# code.I tried using BCP(Bulk copy programming),but unfortunatly its not working.So that option is closed now.How can we do this using C# code?Is it possible?
Many Thanks
|
|
|
|
|
If you must take it into access:
Why not use a text editor, something like gVIM with a :%s/\"/,/g then :%s/,,/,/g command and convert it to a CVS file and do a direct import?
Or you could do an indirect import by 1st going into to excel and picking " as your custom split char, but you MUST remember to import as text!
Not really a reason to parse this though C# code, as you are just going to make it harder on yourself. Remember the simplest solution is most of the time the better soluiton.
The only reason I could see doing this in C# is if you have to process these files many times a day or you wish to learn ADO.NET along the way. The second option doesn't seem viable if you already send Access data into SQL server, so why not modify or fork the program you have to parse the flat file directly into SQL server 2k5?
|
|
|
|
|
Hello everyone,
Two questions about IntPtr,
http://msdn2.microsoft.com/en-us/library/system.intptr(VS.80).aspx
1. does it mean in the internal SDK API implementation System.IO.FileStream, IntPtr is used to hold the native file handle?
2. when do we need to use IntPtr? We have easy to use class like StreamWriter, when and why do we need to use IntPtr?
thanks in advance,
George
|
|
|
|
|
Generally you use IntPtr when using PInvoke for accessing Win32 api calls.
|
|
|
|
|
Thanks Zoltan,
Got your idea. Is my understanding of item 1 correct?
regards,
George
|
|
|
|
|
Yes, check out the rotor source code here[^]
|
|
|
|
|
Thanks Zoltan,
Interested side. Does the site hacking some Microsoft code to produce the code on web (e.g. de-compile) or they just publish some public avaliable code on web?
regards,
George
|
|
|
|
|
No, it's not decompiled code, it is publicly available source from MS.
link[^]
|
|
|
|
|
Cool, Zoltan!
regards,
George
|
|
|
|
|
Hi George,
Microsoft's Rotor demonstrates a possible implementation of the .NET specs.
There is no guarantee the same code is used in any of the official Microsoft .NET releases.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks Luc!
regards,
George
|
|
|
|
|
Hello everyone,
Two questions about the following code,
1. When instance of Class1 is put to GC queue, its wrapped Obj instance is 100% ensured to move to GC queue, but the order of whether the memory and Finalize method of Class1 instance or obj1 instance will be called first can not be decided (GC may make different decision in different situations)?
2. If some instance does not hold the reference of Class1, but holds the reference to obj1 through public method PassOut, in this situation, Class1 instance is prevent from being GCed?
using System;
public class Class1
{
private Component Obj = new Component();
public Component PassOut()
{
return Obj;
}
public Class1()
{
}
}
thanks in advance,
George
|
|
|
|
|
1. no, the order of freeing objects is well defined.
2. yes, in that case Class1 instance is not garbage collected, because the obj1 reference prevents it.
For more information check this link.[^]
|
|
|
|
|
Hi Zoltan,
Zoltan Balazs wrote: 2. yes, in that case Class1 instance is not garbage collected, because the obj1 reference prevents it.
I don't agree.
obj is an object with two references, one inside Class1 instance, one elsewhere.
if the Class1 object is no longer referenced it is collectable; the obj object does
not prevent that, the only link between Class1 and obj is Class1 contains a reference;
obj lives outside of Class1, so it can have an independent life and it does not need Class1.
Hence, obj stays alive thru the "exported" reference, but the Class1 object is dead.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
modified on Saturday, April 19, 2008 9:11 AM
|
|
|
|
|
You're absolutely right, my mistake!
|
|
|
|
|
Sorry, Luc!
I do not fully agree with you that in order to hold reference to obj1, we have to hold reference to class1.
I give you an example,
1. Class2 instance get reference to class1 and from the reference to class1, get reference to obj1;
2. Class2 passes reference to obj1 only to class3 instance, class3.something = class2.obj1;
3. In this way, class3 only holds reference to obj1, but not class1.
Any comments?
regards,
George
|
|
|
|
|
George_George wrote: I do not fully agree with you that in order to hold reference to obj1, we have to hold reference to class1.
You don't have to, and I can't see anywhere that he said so.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|