|
Hello,
I got a program whith PrintPreviewControl, on Win-
2000/XP workstation all fine, but on Win-98 workstation
PrintPreviewControl periodically have the following error:
====================
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set
to an instance of an object.
at
System.Windows.Forms.PrintPreviewControl.CalculatePageInfo
()
at
System.Windows.Forms.Control.InvokeMarshaledCallbacks()
====================
This error also occurs in this MS Example:
http://msdn.microsoft.com/msdnmag/issues/03/02/PrintinginN
ET/default.aspx
Any ideas? I really need to resolve this problem.
Thanks.
|
|
|
|
|
Hey all,
I'm working on an Active Directory web application. I've gotten further than my prior post - if you read my prior post, basically, the problem is this - I have to bind to the LDAP directory as a specific DN to authenticate (the username/password route for AD is not good enough since we are dealing with a non-MS ldap server).
The process is this:
* bind as an anonymous user
* search with a filter of your own devising
* obtain a single directoryentry object
* bind to this directoryentry with the provided password
This seemed like an easy thing to do initially - after all, we do have System.DirectoryServices --- the actual process was a little more involved.
I've done the first three and got them working now (see below for the code). I'm now at step 4 - how do I bind to the directory using an existing DirectoryEntry and a password? My first thought was:
DirectoryEntry bound = new DirectoryEntry(me.Path, "", password, AuthenticationTypes.ServerBind);
... but that does not seem to work (i.e. it always returns) - how can I tell if the binding was successful?
Code to get to this point:
<br />
string path = _host + "/" + _basedn;<br />
DirectoryEntry entry = new DirectoryEntry(path);<br />
Regex r = new Regex(Regex.Escape("$(login)"));<br />
string filter = r.Replace(_filter, username);<br />
DirectorySearcher dsrch = new DirectorySearcher(entry);<br />
dsrch.Filter = filter;<br />
dsrch.SizeLimit = 2;<br />
SearchResultCollection results = dsrch.FindAll();<br />
if (results.Count == 0) return false;<br />
if (results.Count > 1) throw new Exception("Invalid user ID in LDAP Directory");<br />
DirectoryEntry me = results[0].GetDirectoryEntry();<br />
-Adrian
|
|
|
|
|
See if you can repeat this or actually help me solve this problem I'm having.
1) Install DirectX 9.0 C# edition.
2) Create a new project.
3) Add a component or a control to this project.
4) Drag the component/control onto your form and confirm everything is working fine. Delete it once it works.
Now...
5) Add a reference to 'Microsoft.DirectX'
6) Drag the same component/control onto your form and confirm that you get a error message 0x80131019.
7) Delete the reference to 'Microsoft.DirectX'
8) Drag the same component/control back onto your form and confirm that everything is fine.
BTW: If you were to run the application with the component/control and the reference to DirectX, everything works fine.
Any thoughts?
|
|
|
|
|
I am having trouble with this compiling.
The compiler says that invalid array initializer.
<br />
int i1 = 12;<br />
byte[][] bs1 = new byte[][(uint)dnsQuestions.Count];<br />
for (int j1 = 0; j1 < dnsQuestions.Count; j1++)<br />
{<br />
bs1[j1] = ((DnsQuestion)dnsQuestions[j1]).ToByteArray();<br />
i1 += (int)bs1[j1].Length;<br />
}<br />
byte[][] bs2 = new byte[][(uint)answerResourceRecords.Count];<br />
for (int k1 = 0; k1 < answerResourceRecords.Count; k1++)<br />
{<br />
bs2[k1] = ((ResourceRecord)answerResourceRecords[k1]).ToByteArray();<br />
i1 += (int)bs2[k1].Length;<br />
}<br />
byte[][] bs3 = new byte[][(uint)authorityResourceRecords.Count];<br />
for (int i2 = 0; i2 < authorityResourceRecords.Count; i2++)<br />
{<br />
bs3[i2] = ((ResourceRecord)authorityResourceRecords[i2]).ToByteArray();<br />
i1 += (int)bs3[i2].Length;<br />
}<br />
byte[][] bs4 = new byte[][(uint)additionalResourceRecords.Count];<br />
for (int j2 = 0; j2 < additionalResourceRecords.Count; j2++)<br />
{<br />
bs4[j2] = ((ResourceRecord)additionalResourceRecords[j2]).ToByteArray();<br />
i1 += (int)bs4[j2].Length;<br />
}<br />
byte[] bs5 = new byte[(uint)i1];<br />
BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream(bs5));<br />
try<br />
{<br />
BigEndian.Write(binaryWriter, identifier);<br />
BigEndian.Write(binaryWriter, (ushort)flags.Data);<br />
BigEndian.Write(binaryWriter, (ushort)dnsQuestions.Count);<br />
BigEndian.Write(binaryWriter, (ushort)answerResourceRecords.Count);<br />
BigEndian.Write(binaryWriter, (ushort)authorityResourceRecords.Count);<br />
BigEndian.Write(binaryWriter, (ushort)additionalResourceRecords.Count);<br />
for (int k2 = 0; k2 < (int)bs1.Length; k2++)<br />
{<br />
binaryWriter.Write(bs1[k2]);<br />
}<br />
for (int i3 = 0; i3 < (int)bs2.Length; i3++)<br />
{<br />
binaryWriter.Write(bs2[i3]);<br />
}<br />
for (int j3 = 0; j3 < (int)bs3.Length; j3++)<br />
{<br />
binaryWriter.Write(bs3[j3]);<br />
}<br />
for (int k3 = 0; k3 < (int)bs4.Length; k3++)<br />
{<br />
binaryWriter.Write(bs4[k3]);<br />
}<br />
}<br />
finally<br />
{<br />
if (binaryWriter != null)<br />
{<br />
binaryWriter.Close();<br />
binaryWriter = null;<br />
}<br />
}<br />
return bs5;
Any help would make my year.
Thanks
Bo Hunter
|
|
|
|
|
Replace all occurences of [][(uint)dnsQuestions.Count] with [(uint)dnsQuestions.Count][].
|
|
|
|
|
Bo,
I can see two mistakes:
(1) referring to '7.5.10.2 Array creation expressions' in the C# online reference you cannot instantiate the sub-arrays, because the initial value of the first array is null. But in any case this would be an array of new byte [count] []. You try to create a subarray, where no array is created and initiated: new byte [][count] <- this can never work, because the compiler doesn't know how many sub-arrays (i.e. memory) must be initiated.
(2) don't cast to uint, use System.Convert.ToUInt32.
Hope this makes your year
Wolfgang
|
|
|
|
|
So how do I instantiate this?
<br />
<br />
byte[][] bs1 = new byte[(uint)dnsQuestions.Count][];<br />
<br />
for (int j1 = 0; j1 < dnsQuestions.Count; j1++)<br />
{<br />
bs1[j1] = ((DnsQuestion)dnsQuestions[j1]).ToByteArray();<br />
i1 += (int)bs1[j1].Length;<br />
}<br />
<br />
Then how do I instatiate the other part of the array?
<br />
<br />
byte[][] bs1 = new byte[dnsQuestions.Count][dnsQuestions.Count];<br />
<br />
for (int j1 = 0; j1 < dnsQuestions.Count; j1++)<br />
{<br />
bs1[j1] = ((DnsQuestion)dnsQuestions[j1]).ToByteArray();<br />
i1 += (int)bs1[j1].Length;<br />
}<br />
<br />
Like this and IntelliSense says this is wrong.
Thank You
Bo Hunter
|
|
|
|
|
If anyone is willing to take a look at this
project I would be greatfull.
It is Dns query class library with a test app
as well. It runs but I get the Server Faliure
message.
Thanks Again
Bo Hunter
|
|
|
|
|
Hi,
Can anyone tell me how to change column name and column width for a DataGrid (Windows.Forms) that is not bound to a DataSet (i.e. not using DataGrid.TableStyles?)
Thanks in Advance,
[EDIT]
Actually, I just figured out how to edit the names by accessing my DataTable, and figured out how to create a TableStyle dynamically:
DataGridTableStyle myGridTableStyle = new DataGridTableStyle();
However, Help, says you must first create a new DataGridColumnStyle per the table. This:
DataGridColumnStyle myGridColumnStyle = new DataGridColumnStyle();
isn't available, though. Compiler error:
Cannot create an instance of the abstract class or interface 'System.Windows.Forms.DataGridColumnStyle'
So, anyone know how to get around this? I know I have to use DataGridColumnStyle's to change the width of the column, but if I can't create a DataGridColumnStyle I'm at a loss...(And like I said in the original post: no, I can't use the GUI to accomplish this because I'm not using a DataSource via DataSet, etc.)
[/EDIT]
-Idealius
|
|
|
|
|
The DataGridColumnStyle class has over 10 abstract methods, thus cannot be instantiated. The compiler lists the methods that need implementation.
Either you provide (default) implementation, or you may just as well use one of the two ready-to-use derived classes. In MSDN, click on the DataGridColumnStyle item in the TOC, you'll see the class hierarchy, which lists : DataGridBoolColumn and DataGridTextBoxColumn.
|
|
|
|
|
Hi everybody!
I've written a database application ... the database file is a mdb file and the provider is Jet 4.0 OleDB Provider ... the app was fully functional on my pc but when I moved it on another machine that only had .NET Framework it didn't work! A message Box appears with this error:
------------------------------------------
Common language runtime debugging services
Application has generated an exception that couldn't be handled
Process id = 0x.... (-1...), Thread id = 0x.... (-1....)
Click ok to terminate the application
Click cancel to debug the application
--------------------------------
When I fully install the visual studio .net the app works perfectly again! It seems it lacks something when there's only framework installed!
What should I do???
Best regards!
|
|
|
|
|
Make sure to provide the MDAC redistribuable[^] as well.
If you use a particular .NET driver, you might also have to redistribute the corresponding assemblies. If you are using .NET 1.0, more info here[^] (ODBC .NET data provider). Those drivers are now part of the .NET 1.1 run-time (but it's still in beta).
|
|
|
|
|
Of course, this has happened to you...
You had a control, like a MediaPlayer, on your form.
You had it full-sized into a panel, which was not docked
-but anchored in a properly useful way, say 'Top-Left'.
Andi The form loads with the MediaPlayer. Each has its own
size fetched (from last time) from the registry.
So far so good.
The problem start when you resize the form.
You figured that: when the form has loaded the user will
resize the form to his convenience, and load a movie.
That is the user's sole function.
...And...
(The MediaPlayer, ...'Full'y docked into its panel...
will be well-sized with the resized form.)
*Wrong!* (Herein the Jeopardy buzz..)
The MediaPlayer, being docked 'full' into the panel,
is supposed to stretch along the panel as the form is
resized by the user. This seems normal.
Actually, when the user resize the form, the panel is
resized but the MediaPlayer it contains is not resized
along. The MediaPlayer keeps it loaded size even though
its container(the panel) and the form have been resized.
And my question is: 'Why?' -and how can I fix it!!!
Thanks,
Antoine
'Use obstacles as stepping stone' Orison Sweet Marden
|
|
|
|
|
It works for me. I have Windows Media player 6.4 (W2K) :
- create a new windows form app
- insert a panel
- change panel anchor settings to add right and bottom anchors
- insert the media player right inside the panel
- change media player dock settings to "Fill"
|
|
|
|
|
Is it possible to hide a TabPage ? I've tried setting the visible property to false and using the Hide () method but neither seems to hide the page. Is this even possible?
Thanks
|
|
|
|
|
In .NET 1.0, setting the TabPage visible property to false does not change things much. The easiest way to do so is (even if that's a bit lousy) to remove the tabPage item from the TabPages collection.
|
|
|
|
|
.S.Rod. wrote:
The easiest way to do so is (even if that's a bit lousy) to remove the tabPage item from the TabPages collection
If I do this will it destroy the page? I need to be able to add the page back after it's removed and the page isn't created dynamically it's been created in the designer. So if I hide the page this way will I be able to get it back during the life of the application or is it gone until a restart of the program?
Thanks again!
|
|
|
|
|
monrobot13 wrote:
If I do this will it destroy the page?
Not if you first save it off to member variable of the form, so that you can then just re-add the page to the collection.
m_Tp = tabControl1.TabPages[i];<br />
<br />
tabControl1.TabPages.Remove(m_Tp);<br />
<br />
<br />
tabControl.TabPages.Add(m_Tp);
You might have to see how to change the order of the tabs back to the way you had them though. I don't know off hand how to do it.
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I think this will work nicely.
Thanks again all.
- monrobot13
|
|
|
|
|
Most of my tables has GUIDs as PrimaryKeys. So when I create new row in any table, i need to generate new guid and use it as ID. Is there simplier method?
thanks
h.
|
|
|
|
|
I have two controls on a form - checkBox1 and textBox1.
When user "checks" checkBox1, textBox1 becomes visible. Looks pretty simple )
1. without databinding:
textBox1.visible=checkBox1.checked
This works great.
2. let's play with some data in dataset:
I have bound "Checked" property of checkBox1 to a field in DataSet/DataTable. This field is also bounded to textBox1.visible property.
Result:
checkBox1 needs to lost focus to update data in dataTable, so user needs to "check" and next click into some other control.
What should i do to make it working properly (immediately)?
thanks
h.
btw: I have also tryed to force focus changes on the form (this.select(...)). The checkBox needed 2 mouse clicks to synchronize its state with dataset and since then, everything was fine )
|
|
|
|
|
This has popped up several times this week. It is rather annoying (not u, the problem )
You will need to do something like this depending on your databinding:
control.DataBindings[0].BindingManagerBase.EndCurrentEdit();
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
You're right two times in one answer:
1. This problem is REALLY annoying. )
2. This method works well - I have tested 3 different binding modes. There is just one small thing - it needs two more clicks on checkbox to "synchronize". Should I open the row for editing? I have tried to use BeginEdit() method on current row, but there was no difference. I think, that may be a point, but have no idea how to solve it.
Thanks for help
h.
|
|
|
|
|
how to do the following using .NET
I have the following XML document :
3.14159
If I were using COM MSXML parser, I could get
NodeTypedValue property to get "strongly-typed"
value.
b= XMLDocument.SelectSingleNode("//b");
variant value = b.NodeTypedValue;
//now the variant contains double value.
The question is:
how to achieve the same using C# ?
Value property of XMLNode object returns String
type, wchich i have to convert to get desired type...
How to do this without explicit conversion (by the means
of XMLConvert class or similar...)
Thanks
Michal Januszczyk
|
|
|
|
|
May be that's me but I believe that even with MSXML you are supposed to have a separate schema (with attributes of the form dt:type="int") to define node data types.
May be for usability reasons MS indeed allowed to put dt:type attributes along with Xml elements, but that of course didn't apply to define attribute data types since an attribute can hardly be data typed by another attribute.
It's not lost with the .NET Xml parser, just made different. The Xml schema has its own namespace and has the equivalent API you referred to, scattered in this namespace. For instance, System.Xml.Schema.XmlSchemaDatatype.ParseValue() .
PS : the .NET Xml parser is not a wrapper of the MSXML parser, which is a very good design decision. (at least something that stands for itself in this .NET run-time).
|
|
|
|