|
I will post the specific reply at ASP.NET. Thanks.
thanks in advance. Much appreciated.
|
|
|
|
|
Hi. I am currently doing a project using vb.net and c#. Is it possible to temporary remove certain collection item of dropdownlist?
is this the solution:
dropdownlist1.items.remove(items)?
what does (items) refers to?
thanks in advance. Much appreciated.
-- modified at 13:32 Wednesday 5th July, 2006
|
|
|
|
|
Hi all,
i made a simple proxyserver which can display basic HTML page at client site, but i have no idea why the image part of webpage always gone!!
following is my simple code which accept the request from client site, then reponse.
<br />
int port = 8080;<br />
Socket proxyServer = new Socket(AddressFamily.InterNetwork,<br />
SocketType.Stream,ProtocolType.Tcp); <br />
proxyServer.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 5000); <br />
<br />
proxyServer.Bind( new IPEndPoint(GetHostIP(), port) );<br />
proxyServer.Listen( port );<br />
<br />
Console.WriteLine("ProxyServer started at port " + port);<br />
Console.WriteLine("ProxyServer ready for accepting incoming connections..."); <br />
<br />
while(true)<br />
{<br />
Socket clientConnect = proxyServer.Accept(); <br />
NetworkStream clientStream = new NetworkStream( clientConnect, true ); <br />
<br />
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create("http://www.google.co.uk/intl/en_uk/images/logo.gif");<br />
loHttp.Timeout = 10000; <br />
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse(); <br />
<br />
System.IO.StreamReader loResponseStream =<br />
new System.IO.StreamReader(loWebResponse.GetResponseStream()<br />
, System.Text.Encoding.UTF8);<br />
<br />
<br />
Byte[] buf = System.Text.Encoding.UTF8.GetBytes( loResponseStream.ReadToEnd() );<br />
<br />
loWebResponse.Close();<br />
loResponseStream.Close();<br />
<br />
<br />
clientStream.Write(buf, 0, buf.Length);<br />
clientStream.Flush();<br />
clientStream.Close();<br />
}<br />
plz help me out~~
many thanks!
|
|
|
|
|
Bluebamboo wrote: plz help me out
Isolate the code that downloads the GIF file and unit test it.
|
|
|
|
|
Hi mike,
Thanks for your reply,but i am not quite clear about what you said, do you mean i should save my code part in GIF format file then upload it? GIF? a picture?
|
|
|
|
|
The part that uses a HttpWebRequest to download the image file resulting in a byte array containing the image. That should be isolated and unit tested. The unit test could save the byte array to a disk file that can be verified to be correct. None of that has anything to do with your "proxyServer" and sending the byte array to the client socket. That is why it can and should be "isolated". Take some time to read about software design principles.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
How to count total properties in a class.
suneet
|
|
|
|
|
typeof(SomeClass).GetProperties().Length
:josh:
My WPF Blog[^]
|
|
|
|
|
Thanks Josh..........for your help...this worked.....
suneet
|
|
|
|
|
Hi all. I need to call a method of my .NET COM-object from Word. How can I do it?
I've written an object, checked all these "COMVisible", "register for COM Interop" etc.
In Word I can see a reference to it. After adding the reference I write the script:
Dim Ob As Object
Set Ob = CreateObject("ClassLibrary1.FOO")
On CreateObject line I get: "Run time error 429. ActiveX component can't create object".
Or if I write so:
Dim Ob As Object
Set Ob = New Classlibrary1.FOO
I get: "Run-time error -2147024894 (80070002). File or assembly Classlibrary1, or one of it's dependencies was not found".
Which dependencies? It's just a test project! Here is the source code:
using System;
using System.Runtime.InteropServices;
namespace Chapter_Code
{
[GuidAttribute("1C6CD700-A37B-4295-9CC9-D7392FDD425D")]
public interface IFoo
{
string PrintMe();
int ShowState();
void SetState(int newState);
}
[GuidAttribute("C09E2DD6-03EE-4fef-BB84-05D3422DD3D9")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ProgIdAttribute("Chapter_Code.Foo")]
public class Foo : IFoo
{
public Foo() { }
private int state = 100;
public string PrintMe()
{
return ("TEST SUCCESS");
}
public int ShowState()
{
return (state);
}
public void SetState(int newState)
{
state = newState;
}
}
}
Your help is much appreciated!
Knows where to go everyday.
|
|
|
|
|
Did you use regsvr32 on the com object?
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
it's .NET COM object, so I used "regasm CodeLibrary1.dll /codebase".
There were some little mistakes in namespace and ProgID in my code. So here is the final variant:
using System;
using System.Runtime.InteropServices;
namespace ClassLibrary1
{
[GuidAttribute("1C6CD700-A37B-4295-9CC9-D7392FDD425D"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IFoo
{
[DispId(1)]
string PrintMe();
[DispId(2)]
int ShowState();
[DispId(3)]
void SetState(int newState);
}
[GuidAttribute("C09E2DD6-03EE-4fef-BB84-05D3422DD3D9"),
ClassInterfaceAttribute(ClassInterfaceType.None)]
[ProgIdAttribute("ClassLibrary1.Foo")]
public class Foo : IFoo
{
public Foo() { }
private int state = 100;
public string PrintMe()
{
return ("TEST SUCCESS");
}
public int ShowState()
{
return (state);
}
public void SetState(int newState)
{
state = newState;
}
}
}
Now using CreateObject or New gets the same error: "Run-time error -2147024894 (80070002). File or assembly Classlibrary1, or one of it's dependencies was not found".
|
|
|
|
|
Hi,
I wanna to format any date like SQL Date without changing Regional setting? Where I wanna 2 send a date in a field in sql-server of type date but it changes automatically 2 system format, so I must change regional setting, But I dont like this way
Can Anyone Help me, with a solution?
23DoorsDown
Regards,
Hisham Galal <me4webby@yahoo.com>
|
|
|
|
|
The following function will format a datetime like the old vb dateformat and return a varchar. I use this all the time to format dates in my applications.
/****** Object: UserDefinedFunction [dbo].[udf_FormatDate] Script Date: 07/05/2006 11:11:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create FUNCTION [dbo].[udf_FormatDate] (@date datetime, @format varchar(50))
RETURNS VARCHAR(50) AS
BEGIN
-------------------------------------------------------------------------------------
--
-- Name: FormatDate
--
-- Purpose: Mimics the VB Format routine for dates
--
-- Parameters:
-- @date - Date, Date to be formatted
-- @format - String, Template to format the date to
--
-- Returns: String, Date formatted to user requested template
--
-- Notes:
-- 1. Time information is not accounted for in this routine
--
-- 2. @format accepts the following values for each section of the date.
-- Day
-- dddd - Full Day Name
-- ddd - Abbreviated Day Name
-- dd - Zero Padded Day Number
-- d - Day Number
--
-- Month
-- mmmm - Full Month Name
-- mmm - Abbreviated Month Name
-- mm - Zero Padded Month Number
-- m - Month Number
--
-- Year
-- yyyy - Full 4 digit year
-- yy - 2 digit year
--
-- 3. Any unexpected characters will be returned in the string
--
-- 4. Assumes database was set up with case-insensitive collation
--
-- Example Usage:
-- All examples use the following date 2003-07-13 00:00:00
--
-- 'dddd, mmmm dd, yyyy' --> Sunday, July 13, 2003
-- 'mmddyyyy' --> 07132003
-- 'm-d-yy' --> 7-13-03
-- 'mm/dd/yyyy' --> 07/13/2003
--
-------------------------------------------------------------------------------------
DECLARE @pos AS INTEGER
DECLARE @char AS VARCHAR(1)
--
-- Replace Year
--
SET @pos = CHARINDEX('yyyy', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 4, DATENAME(yyyy, @date))
--PRINT @format
SET @pos = CHARINDEX('yyyy', @format)
END
SET @pos = CHARINDEX('yy', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 2, RIGHT(DATENAME(yyyy, @date) ,2))
--PRINT @format
SET @pos = CHARINDEX('yy', @format)
END
--
-- Replace Month
--
SET @pos = CHARINDEX('mmmm', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 4, DATENAME(month, @date))
--PRINT @format
SET @pos = CHARINDEX('mmmm', @format)
END
SET @pos = CHARINDEX('mmm', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 3, LEFT(DATENAME(month, @date), 3))
--PRINT @format
SET @pos = CHARINDEX('mmm', @format)
END
SET @pos = CHARINDEX('mm', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 2, RIGHT(('0' + CAST(DATEPART(month, @date) AS VARCHAR(2))), 2))
--PRINT @format
SET @pos = CHARINDEX('mm', @format)
END
SET @pos = CHARINDEX('m', @format)
WHILE @pos > 0
BEGIN
-- account for MArch and deceMBer
SET @char = SUBSTRING(@format, @pos + 1, 1)
IF (@char <> 'a') AND (@char <> 'b')
BEGIN
SET @format = STUFF(@format, @pos, 1, CAST(DATEPART(month, @date) AS VARCHAR(2)))
--PRINT @format
SET @pos = CHARINDEX('m', @format)
END
ELSE
BEGIN
SET @pos = CHARINDEX('m', @format, @pos + 1)
END
END
--
-- Replace Day
--
SET @pos = CHARINDEX('dddd', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 4, DATENAME(weekday, @date))
--PRINT @format
SET @pos = CHARINDEX('dddd', @format)
END
SET @pos = CHARINDEX('ddd', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 3, LEFT(DATENAME(weekday, @date), 3))
--PRINT @format
SET @pos = CHARINDEX('ddd', @format)
END
SET @pos = CHARINDEX('dd', @format)
WHILE @pos > 0
BEGIN
SET @format = STUFF(@format, @pos, 2, RIGHT(('0' + DATENAME(day, @date)), 2))
--PRINT @format
SET @pos = CHARINDEX('dd', @format)
END
SET @pos = CHARINDEX('d', @format)
WHILE @pos > 0
BEGIN
-- account for DEcember, sunDAy --> saturDAy, weDNesday
SET @char = SUBSTRING(@format, @pos + 1, 1)
IF (@char <> 'e') AND (@char <> 'a') AND (@char <> 'n')
BEGIN
SET @format = STUFF(@format, @pos, 1, CAST(DATEPART(day, @date) AS VARCHAR(2)))
--PRINT @format
SET @pos = CHARINDEX('d', @format)
END
ELSE
BEGIN
SET @pos = CHARINDEX('d', @format, @pos + 1)
END
END
IF @format = '//' BEGIN
SET @format = ''
END
RETURN @format
END
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
|
You could only work with UTC time in your application.
DateTime.UtcNow;
DateTime.ToUniversalTime();
Hope it helps.
All the best,
Martin
|
|
|
|
|
Hi,
I have doubt by using Shadowcopying. Please anyone give samples and explanation how shadow copy is working in .net windows forms using c#.
Thanks,
kokila.
|
|
|
|
|
Shadow copying is a feature of the ASP.NET runtime. It is not used in WinForms because the WinForms compilation model is not dynamic.
Josh
:josh:
My WPF Blog[^]
|
|
|
|
|
WinForms does use ShadowCopy. Actually, the .NET framework itself uses this method also. When an assembly is loaded from the GAC it is really using a shadowcopy, this allows assemblies in the GAC to be updated without the risk of being locked by an application.
Using the AppDomainSetup object you can set the path and whether or not to use shadowcopy when creating a new AppDomain. I have used this method to load assemblies for use in an application and allow them to be updated while the app is running. If the assembly is updated the AppDomain is unloaded and created again there by getting the newer version for use while the app remains active for the user.
|
|
|
|
|
Thanks for the info! I never knew that.
:josh:
My WPF Blog[^]
|
|
|
|
|
Hi,
Thanks for your information. Please i need the sample code which you are using for shadow copying.i have tried the same.But newer version is not updated.
|
|
|
|
|
I have a Windows Form (Form1 is class name) which is the GUI for my app. In Form1 class I have some methods for writing to a textbox. In the same namespace I have another class from which I would like to call Form1's method for writing to that textbox.
Question: How can I call Form1's methods from the another class. I understand how to make calls across classes using instances, but how can I do this when I dont have an instance of Form1 in the other classes? I've tried using static modifiers to Form1's textbox function but that brings up other problems.
So how can I access the Form1's members and methods from another class??
Thanks
|
|
|
|
|
You'd have to find a way to get a reference to the running form. Don't know how you would accomplish that unless the form is instantiating the class in question.
However, what you described sounds like a design choice you should probably reconsider. Instead of having a class that alters a text field, you might want to have that class just take some input and return a string so that any form with a text box can use that functionality.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
First, although there are other alternatives, in your case it's better for other classes to call Form1 object. Static methods are not a good option here, as you may want to handle multiple Form1 instances.
Second, Form1's data members aren't supposed to be accessed/altered directly by other classes. A better design would be adding Property to Form1. Outsiders access Form1 properties and Form1 binds these properties with its own controls.
Best,
Jun
|
|
|
|
|
Jun Du wrote: A better design would be adding Property to Form1. Outsiders access Form1 properties and Form1 binds these properties with its own controls.
Not much better, a better design would use MVC Pattern.
|
|
|
|
|