|
ASGill wrote:
Im trying to implement a function where a message will pop up, say a week before a particular expiry date and every day after that, until the expiry date
That is a bit vague. What is the mechanism for determining the expiry date. At what point is the message to pop-up? (Application start? Or is is supposed to sit in the background somewhere until it needs to display a reminder?)
ASGill wrote:
and is there a namespace to make this function easier?
What do you mean by this? Do you mean is there a class to make this easier? Perhaps the System.Threading.Timer[^] class would be helpful.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
well the message is supposed to sit in the background and pops up when it needs to display a reminder.
thx for the information abt the class...ill look into it.
CODER
|
|
|
|
|
Look up the System.PopupWindows.ExpiryDateNotifyBallon class
|
|
|
|
|
Hi,
I want to convert variables of type double to type float in my C# app.
I've read that casting from a double to float results in the double being rounded to the nearest float value. That is exactly what I need (as opposed to truncation).
However, I've also seen that the Convert.ToSingle(double) method uses rounding as well to convert the double to a float.
Is there any difference between these two techniques - casting and ToSingle? Are there scenarios in which one is preferable over the other? What about overhead?
Thanks!
|
|
|
|
|
I don't know technical point of this but from my personal expirience I ecourage everyone to use Convert.To... over casting because several times it happened to me that (casting) produced error and on contratry Convert.To... never made any trouble.
|
|
|
|
|
crushinghellhammer wrote:
Is there any difference between these two techniques - casting and ToSingle?
The basic difference is that a cast can thrown an exception which means anytime you cast something you should also wrap it in a try/catch block to handle any exception that is thrown. This in turn emits additional IL instructions, not much but it's there.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I want to create a secure Access-Database from C#.
I want to create a Database and a Systemdatabase - I suppose this works only in the same time.
Why does the following code not work?
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
ADOX.Catalog catalog = new ADOX.Catalog();<br />
catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\\new.mdb;Jet OLEDB:System Database=e:\\new.mdw;Jet OLEDB:Create System Database=true");<br />
}
- it creates the e:\new.mdb but fails to create the e:\new.mdw.
the e:\new.mdb is not accessible.
I use Visual Studio 2003 and I have tried this
- on W2K with installed Access97 and Access2000 and
- on WXP with installed Access2003
All with the same result.
|
|
|
|
|
Hi,
In Visual c# 2005 Express, the code below will throw the following exception when accessing www.amazon.com. This does not happen in older versions of the .NET Framework. Why is this happening? Not sure what the violation here is. Using a different program, I can see that the returned headers by amazon.com look like this:
HTTP/1.1 301 Moved Permanently
Date: Tue, 27 Jul 2004 18:54:05 GMT
Server: Stronghold/2.4.2 Apache/1.3.6 C2NetEU/2412 (Unix) amarewrite/0.1 mod_fastcgi/2.2.12
Set-Cookie: skin=; domain=.amazon.com; path=/; expires=Wed, 01-Aug-01 12:00:00 GMT
Location: http://www.amazon.com:80/exec/obidos/subst/home/home.html
Connection: close
Content-Type: text/plain
EXCEPTION:
at System.Net.HttpWebRequest.CheckFinalStatus(Boolean mustThrow)
at System.Net.HttpWebRequest.GetResponse()
at ProtocolViolation.ProtocolViolation.GetHTML(String url_) in c:\documents a
nd settings\administrator\local settings\application data\temporary projects\con
soleapplication1\program.cs:line 21
CODE:
using System;
using System.Net;
namespace ProtocolViolation
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class ProtocolViolation
{
public static string GetHTML(string url_)
{
HttpWebResponse response = null;
HttpWebRequest request = null;
try
{
request = (HttpWebRequest)(WebRequest.Create(url_));
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception e)
{
Console.WriteLine(e);
}
finally
{
if (response != null)
{
response.Close();
}
request = null;
response = null;
}
return "";
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
while (true)
{
GetHTML("http://www.amazon.com:80/exec/obidos/subst/home/home.html");
}
}
}
}
Thanx, amir
|
|
|
|
|
Why don't you try something like this:
private string GetHtml(string url)
{
WebRequest wreq;
WebResponse wres;
StreamReader sr;
String content = string.Empty;
wreq = HttpWebRequest.Create(url);
wres = wreq.GetResponse();
sr = new StreamReader(wres.GetResponseStream());
content = sr.ReadToEnd();
sr.Close();
return content;
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
That does not solve the problem. I still get an exception. It would solve it if casting the response would be the cause of the problem. It goes deeper than that into issues with GetResponse(). This is not happening in .NET Framework versions lower than 2.0
You need to DL the C# .NET 2005 Express to see this happening.
Amir
|
|
|
|
|
amir z wrote:
You need to DL the C# .NET 2005 Express to see this happening.
I have .NET 2005 running on my laptop, in fact here is a dump from a test program I wrote, which works fine.
#region Using directives
using System;
using System.IO;
using System.Net;
using System.Collections.Generic;
using System.Text;
#endregion
namespace Example
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
Console.WriteLine(p.GetHtml("http://www.yahoo.com"));
Console.Read();
}
public string GetHtml(string url)
{
WebRequest wreq;
WebResponse wres;
StreamReader sr;
String content = string.Empty;
wreq = HttpWebRequest.Create(url);
wres = wreq.GetResponse();
sr = new StreamReader(wres.GetResponseStream());
content = sr.ReadToEnd();
sr.Close();
return content;
}
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
yeah, i never said it doesn't work with every site. so far, i only noticed it happen on amazon.com. go visit http://www.amazon.com with your code. you'll see what happens. and the old framework does not throw any exception when i visit amazon.
-amir
|
|
|
|
|
There is nothing about the code that requires .Net 2.0 or Dev Studio 2005.
In any event, the code works for me under both .Net 1.0 and 1.1 against both yahoo and amazon. Are you sure you aren't trying to run this thing behind a firewall?
|
|
|
|
|
I have other reasons for using 2.0. This is just a sample. I know that you can access amazon and yahoo from 1.0 and 1.1.
Like i said, it is only 2.0 that is giving the problem.
thanx, amir
|
|
|
|
|
I'd like to create some controls that have unusual shapes. i.e. Oval, Diamond, picture.
The problem is, all controls appear to be represented as rectangles.
How can I make a control a custom shape? There is no region or size map that I can see that determines what shape a control is, so where does the MouseOver event get it's information?
I was thinking of using some Region map to draw my control, and limit it's painting to that. But i'm not sure where to begin.
Failing this, i would have to create some kind of transparent control, but this leaves me with the problem of custom controls hiding controls they overlap with in transparent areas. I believe this is due to UserControls handling their own paint methods.
Any advice on where to start would be appreciated.
Cata
|
|
|
|
|
Use
GraphicsPath to definet the shape, then use control.Region to set the region shape.
Creating Bitmap Regions for Forms and Buttons[^] shows how
Gary
"A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck."
Tom Shales talking about Robin Williams
|
|
|
|
|
hello,
My Web Service accesses to a MS SQL database to store and retrieve data from it.
but to store data, first I must to create programatacally the database and the tables. My question is what is the best way to do this? where is the best place to put the code which do this? In the beginning of each Web method (if the database and the tables do not exist, of course) or there is a common place to create or to initialize data, structures, systems, connections, etc.?
thanks in advance.
|
|
|
|
|
Actually, the best way to do it is to run the SQL script that creates everything either ahead of time, or when the Web Service is installed. Checking for the existance of the database on every call is very unecessary and just wastes time and resources doing the checks for something will only be done once.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
pelos wrote:
first I must to create programatacally the database and the tables. My question is what is the best way to do this?
Don't forget to add data. Aside from what Dave said I think you may be confusing two aspects of the software development lifecycle. You can manually type the DDL to create your database, tables and insert data into or you can use the visual tools that popular RDBMS provide. The purpose of web services is to allow a tranparent transport protocol regardless of operating system for data flow. Does that make sense?
- Nick Parker My Blog | My Articles
|
|
|
|
|
I've built myself a custom app wizard for VS.NET 2003. Everything is working great.
However I now want to use the wizard on another machine.
I currently have a hard-coded path I use in my AddFromTemplate call
proj = sol.AddFromTemplate("C:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC#\\VC#Wizards\\DefaultWinExe.csproj", localDirectory, projectName, true);
Is there a way of determining where VS.NET is installed so that I don't have to hard-code the path. I've not seen a useable property in the DTE object model... but then again the documenation isn't the best in the world.
Any suggestions on where I can get the path whilst within my IDTWizard derived class.
Michael
CP Blog [^]
|
|
|
|
|
There's the DTE.FullName property that gives you the full path to the devenv.exe executable. You can use various Path methods (or just parse the string yourself) to get the base directory and then append the VC# directory.
You could also use the DTE.RegistryRoot key. That would give you a place to start to use the RegistryKey class that you could find the actual path to the VC# directory (just in case it was installed outside the VS.NET installation root somehow).
Finally, another way would be to use Process.GetCurrentProcess , then get the MainModule and get that return value's FileName , which is the full path to the executable hosting your code. This is a bit of a kuldge, though, but would work with other designers (like #develop, for example).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
There's the DTE.FullName property that gives you the full path to the devenv.exe executable. You can use various Path methods (or just parse the string yourself) to get the base directory and then append the VC# directory.
I'll have a look at that one. Probably more reliable than directly reading the info from the registry which is my current solution.
thanks for the advice,
Michael
CP Blog [^]
|
|
|
|
|
System.RunTime.InteropServices.COMException : A device attached to system is not functioning
at System.DirectoryServices.Interop.IAds.SetInfo();
this happen when i try a C# program which add users to administrators group.
When i add to another group like print operators,guests...everything is fine.
Anybody know how to solve this?
|
|
|
|
|
This may seem like a stupid question, but is the account that the app is running under have Admin rights to the machine?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
it's using administrator account, and one more, do you know how to do operation delete object, move object starting by authenticate and authorize the user first..
for example we use a username and password to do such an operation, so that whether such operation can be completed or not depends on the permissions given to given username.
I found that the permissions is applied according to windows account that is currently logged on and using the program.
What i want is the program itself will have its authentication & authorization independent of what account is actually used to logged on to windows.
Thanks
|
|
|
|