|
Run another pass with the encoded text through the following function:
using System.Text;<br />
<br />
public string fixPipes(string text)<br />
{<br />
char ch = ASCIIEncoding.ASCII.GetChars(new byte[] { 0x7C });<br />
char pipe = '|';<br />
<br />
return text.Replace(ch,pipe);<br />
}
That should do the trick. After that you can post the link to allmusic without problems.
"Every rule in a world of bits and bytes can be bend or eventually be broken"
|
|
|
|
|
Hi,
Thanks for the reply, don't have a problem generating the URL, the problem arises when you use the HttpWebRequest class since it performs the urlencode regardless of the input string (i.e. even though I am passing a URL with pipe characters, when I sniff the outbound HTTP request, you can see that it has transcoded it to %7C).
I need a way to suppress this functionaliy.... any ideas??
|
|
|
|
|
How to use classes from another project without adding this classes to the current project...
Devil Linux
|
|
|
|
|
You load the Dll of used project into your current project. I give to you some code:
Imports System.Reflection
.........
.........
Dim objClass As Object
Dim tType As Type
Dim strFileName As String
Dim strClassName As String
strFileName = "D:\Setup\TaoMenuDong\Test\bin\Test.dll"
strClassName = "Test.Form1"
Dim MyAssembly As [Assembly] = [Assembly].LoadFile(strFileName)
objClass = MyAssembly.CreateInstance(strClassName)
tType = MyAssembly.GetType(strClassName)
Dim PIF As PropertyInfo
PIF = tType.GetProperty("strDuLieu")
PIF.SetValue(objClass, "OK, Don't move, what's your name, bud", Nothing)
Dim Res As String
Res = PIF.GetValue(objClass, Nothing)
MessageBox.Show(Res)
|
|
|
|
|
thankx Mr. nxdess,
but, I want using class from class without uload DLL file.
Devil Linux
|
|
|
|
|
Hi
I'm trying to write some code in C# for displaying a MSChart in Microsoft Word. Ofcourse, I use automation. My code works well with libraries Word 9, MSGraph 8 (of Office 2000). The problem come when I use Office 97 (MSGraph 8, Word 8). After debuging, I see it's because the Object represented for the Chart cannot be casted to the Graph.Chart type. Following is a part of the code:
private object oMissing = System.Reflection.Missing.Value;
Word.Range wrdRng;
Word.InlineShape oShape;
...........
........
object oClassType = "MSGraph.Chart.8";
oShape = wrdRng.InlineShapes.AddOLEObject(ref oClassType, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ref oMissing, ref oMissing, ref oMissing);
Graph.Chart chart= (Graph.Chart) oShape.OLEFormat.Object;
The last statement throw an exception System.InvalidCastException with a message : Additional information: Specified cast is not valid.
I also use a similar code for VB6 from address: support.microsoft.com/support/kb/articles/q244/5/89.asp but the result doesn't change
Help me!
Thanks!
|
|
|
|
|
Hi,
I'm a little confused on why I'm getting this error message:
"DataTable already belongs to another DataSet"
Here is the situation….
I'm passing two DataTables to another Form (to generate a crystal report) so they are public in the new Form. This new Form adds both DataTables to a DataSet (to send to the report). The first load of the report Form works fine, the second time around, I get the error message. If I reload the DataTables in the first Form (with the exact data), It works fine each time. I thought the DataSet would be nuked when you close the Form that created it (.Show is used to load report Form)
Could it be that the original DataTables (in first Form) are now in a DataSet, which was created in the second Form? New to programming )
thanks,
Ron
|
|
|
|
|
Add the DataTable to the DataSet only once (perhaps in the code that shows the report) but then pass a reference to the DataSet as parameters to methods or as properties.
Most objects in .NET are references, so passing around the variables is actually passing around a reference to the original object. Only a handful of types - your primitives (numbers and bool), structures, and enumerations - are value types and passed by value, so any changes to them won't change the original.
The problem you're experience is exactly what the error tells you - the DataTable already belongs to another DataSet and cannot be added to another one. Because your code is being executed twice, the table is added (or, rather, you're trying to add) to two different instances of a DataSet .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks Heath,
I add the datatables to the dataset in the first form, this way the datatables are not added every time I load the report Form (like you said).
|
|
|
|
|
i have a string "13255ad27d"
this string it not fixed it might be "1212221121"
but i know that the lenth is fixed = 10
wonna count how many 0,1,2.....9 and A,B,C...F
if string is "1212221121"
A=0
B=0
1=5
2=5
3=0
4=0
do this from 0-9 and A-f
|
|
|
|
|
Here is a nice quick way of doing this:
string text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris ut dui vitae nulla eleifend malesuada. Aliquam semper tortor nec arcu. Donec consequat tincidunt ipsum. Praesent tempor magna nec massa. Curabitur ut tortor. Fusce massa. Pellentesque vulputate, ante quis mattis euismod, magna elit pretium enim, eu varius nisl eros vel nisl. Pellentesque quis enim. Phasellus eu erat. Ut convallis pede quis purus. Aliquam nec diam ut mauris congue suscipit. Nam eleifend congue sapien. Cras vulputate erat id ligula. Suspendisse potenti. Sed laoreet aliquet lorem.";
Hashtable charCounter = new Hashtable();
foreach(char c in text.ToCharArray())
{
if (charCounter.ContainsKey(c))
{
charCounter[c] = (int)charCounter[c] + 1;
}
else
{
charCounter.Add(c, 0);
}
}
foreach(char c in charCounter.Keys)
{
System.Diagnostics.Trace.WriteLine("Char: " + c + " " + charCounter[c]);
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
I add a user control to my project, I then inherit from a TabPage. I add controls to the designer but when I switch between code and designer view i get an error
"Operation not valid due to the current state of the object" Lost many sleepless hours over this. It is now 3.46 am here and i am bit tired hope i wake and see the end of this error.
here is the compile message
'DefaultDomain': Loaded 'c:\winnt\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'createControls': Loaded 'G:\DomesticAndGeneral\DGIWork\createControls\bin\Debug\createControls.exe', Symbols loaded.
'createControls.exe': Loaded 'c:\winnt\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'createControls.exe': Loaded 'c:\winnt\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'createControls.exe': Loaded 'c:\winnt\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
'createControls.exe': Loaded 'c:\winnt\assembly\gac\c1.win.c1flexgrid\2.1.20031.104__c9c7ad9c0a5706c9\c1.win.c1flexgrid.dll', No symbols loaded.
'createControls.exe': Loaded 'c:\winnt\assembly\gac\c1.common\1.0.20031.116__e272bb32d11b1948\c1.common.dll', No symbols loaded.
'createControls.exe': Loaded 'c:\winnt\assembly\gac\c1.win.c1input\1.0.20031.0__7e7ff60f0c214f9a\c1.win.c1input.dll', No symbols loaded.
'createControls.exe': Loaded 'c:\winnt\assembly\gac\accessibility\1.0.5000.0__b03f5f7f11d50a3a\accessibility.dll', No symbols loaded.
'createControls.exe': Loaded 'c:\winnt\assembly\gac\system.design\1.0.5000.0__b03f5f7f11d50a3a\system.design.dll', No symbols loaded.
The program '[6432] createControls.exe' has exited with code 0 (0x0).
|
|
|
|
|
Well the code of the User Control might help. At least maybe the contructor and component initialization. It looks like you might have some invalid code in the user control. The designer has to instantiate and load the control in design mode. You need to make sure the code doesn't exception out or set any invalid arguments in the default constructor.
-
Drew
|
|
|
|
|
when i change the inheritance back to a usercontrol it compiles ok and no problems with the symbols but when i inherit from the tabpage it goes looses the symbols and every control i have on the page is an error. with 3000 lines of code a bit much to show unless i can email it?
|
|
|
|
|
Hello one more time (and last time for the time being )
In one of those forms I was talking about on my previous posts, I have a multiline textbox. The user types some text, presses Enter, and some more text. The data is correctly saved, and the form closes. But when I open the form again and display the text in the multiline textbox, it is displayed on a single line with some unreadable characters where line breaks should go.
I know is a problem of LF vs CRLF but my question is why if I take the text from a text box and then set it back, the line breaks are not recgonized. And, any quick way to fix it?
Thanks,
-- LuisR
___________
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
|
|
|
|
|
How are you "saving" this data? It's important that you always use Environment.NewLine which is correctly defined on the platform on which the CLI implementation (.NET is Microsoft's implementation of the CLI).
If you're saving this text using a TextWriter , it should be saved with the correct line-ending.
The encoding could also matter. Make sure that you read and write with the same encoding. If you save using a Unicode encoding and then read the file back in using a 7- or 8-bit encoding like ASCII - or even a multi-byte encoding like UTF8 depending on the characters being encoded - you will notice problems (because the bytes would be 0x0d,0x00,0x0a,0x00, not 0x0d,0x0a).
If you could provide more information, that would also be helpful.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath Stewart wrote:
How are you "saving" this data?
person.Address = txtAddress.Text; // person.Address is a string property
And then:
txtAddress.Text = person.Address;
And sometimes in between it is saved to and read from a database with a:
strSQL = "UPDATE ..... Address='" + person.Address + "' ....";
and read from the database with a:
person.Adress = datareader.GetString(...);
When I try output that person.Address to a printer, it comes out correctly in several lines.
Now that I'm typing it here, I'm thinking that the problem could be in the UPDATE statement. Any ideas?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
The first problem with your UPDATE statement is...
...NEVER use string concatentation to build SQL queries! Thing for a moment what happens when I set txtAddress.Text to the following (which gets assigned to person.Address , which gets passed to your query):
blah' AND 1=1; DROP TABLE YourTable; -- You get 0wned - that's with a zero. If you store credit card numbers, I could grab those. And don't think I can't - I can easily read your IL and string literals with tools that even come in the .NET Framework SDK (ildasm.exe). Major RDBMS's like SQL Server and Oracle support quering for schema information, so I can also find out what columns, tables, views, and databases you have (among other things).
Use parameterized queries. If this is for SQL Server, you'd use the SqlCommand.Parameters collection property, which is well-documented and includes examples. Be sure to read them, because different ADO.NET providers provide support parameters differently: both SQL Server and Oracle drivers support named parameters (but identified a little differently), while the OLE DB provider you must use question marks (?).
The problem could be in how your storing the data. All strings are encoded somehow, and your database encoding might be the problem - same as I mentioned for the text files (though databases typically abstract this problem away).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath Stewart wrote:
...NEVER use string concatentation to build SQL queries!
You got a very good point there. I had not thought of that before, but in this particular case, this would not be a problem. It's a very little Windows Forms app using a VistaDB database (similar to an Access database, a single file, residing locally). But I definitely need to look into parametized queries.
On Monday, I'll take a look at how the database does the string encoding. If I remember correctly, the multiline text box shows only one non-printable character where a line break should go, so I could probably fix it by adding a carriage return if only a new-line is present, or viceversa.
Thanks, and I'll keep you informed of my findings.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Luis Alonso Ramos wrote:
but in this particular case, this would not be a problem.
I never said it was the problem, but it's a serious problem nonetheless. SQL injection attacks are one of the most overlooked problems and the easiest to exploit. Add to the problem that too many people run as privileged accounts. Always use the least privileges required. You should set up a separate account for your web site (if using database authentication) or add your ASP.NET account (by default, the local ASPNET account added during installation of the .NET Framework) if using SSPI (Windows Integrated Authentication) and give it only the privileges on objects (tables, views, and stored procedures) that are necessary.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello again,
On the same app I talked about the previous thread, my MDI child form has a toolbar and many textboxes.
I use the textboxes' Validated event to set a modified flag and save the value to an internal object. When I click the Save button on the MDI child toolbar, the object is saved to the database.
My problem is that if I modify a text box, and then click the save button on the toolbar, the Validating/Validated events are not generated, because the textbox doesn't lose focus. I have to go to another control, and then click save on the toolbar.
Any ideas on how to fix this or why this is happening?
-- LuisR
___________
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
|
|
|
|
|
Make sure CausesValidation is set to true.
If you have a custom control that was implemented differently you can force validation. My company used the following code in some of our projects:
public class Tasks
{
public static void ForceControlValidation(Control c)
{
Type t = typeof(Control);
MethodInfo m = t.GetMethod("NotifyValidating", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic);
object obj = m.Invoke(c, new object[0]);
if (obj is bool && (bool)obj == false)
{
MethodInfo m2 = t.GetMethod("NotifyValidated", BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic);
m2.Invoke(c, new object[0]);
}
}
}
Does anyone have something that works better? Please let me know.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Alex Korchemniy wrote:
Make sure CausesValidation is set to true.
All controls have CausesValidation set to true.
The Validating/Validated events are generated when the control loses focus, for every control. But when I click on the toolbar, the focused control doesn't lose it. That's why it's value is not saved.
If I modify a control, click on some other control, and then the toolbar, there is no problem.
-- LuisR
___________
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
|
|
|
|
|
The ToolBar class in the BCL - and most other third-party toolbars I've seen - never gain the focus.
You need to invoke validation when a button is clicked. Since the ToolBar class in the BCL fires a single event for any button click, it makes it easy to do this: just call the function that implements your functionality before checking which button was clicked (well, in most cases I would imagine).
How do you implement this? There are several ways, such as recursively enumerating your Controls collection for each Control (starting at your Form , UserControl , or whatever control you're extending or using for your container) and check the Focused property defined by the Control class (so every control has it, but they may not implement it - like the Panel class).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath Stewart wrote:
The ToolBar class in the BCL - and most other third-party toolbars I've seen - never gain the focus.
So, that's the problem then.
Heath Stewart wrote:
There are several ways, such as recursively enumerating your Controls collection for each Control
That's easy enough. I'll implement it Monday morning.
Thanks for your help!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|