|
Christian Graus wrote: if you need to buys a library
I hope you remember this[^].
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
"without client knowledge" - the whole process of sending faxes should be run on the server, without client even knowing that faxing was started. Fax will be sent to third party. Fax number is in database.
.html documents are saved on server.
I've found option to send fax via e-mail, but "this type of e-mail to fax will generate pages approximately 80 characters wide using 11 point courier font. Ascii graphics and special characters may or may not look correct when faxed. Keep your text simple."
"...And then she'd say, it's Ok, I got lost on the way
but I'm a supergirl, and supergirls don't cry. ..."
Reamonn
|
|
|
|
|
Hi,
I am working through a GOF design pattern, and I am not understanding a section of the code.
class Singleton
{
private static Singleton instance;
protected Singleton()
{
}
public static Singleton Instance()
{
if (instance == null)
{
instance = new Singleton();
}
return instance;
}
}
Here is the other piece of code:
class MainApp
{
static void Main()
{
Singleton s1 = Singleton.Instance();
Singleton s2 = Singleton.Instance();
}
}
Why is this possible in the Singleton class..
instance = new Singleton();
..but in the class MainApp I cannot instantiate a Singleton() instance?
Please can someone help me with my confusion?
Thanks
Brendan
|
|
|
|
|
.NET Enthusiast wrote: Why is this possible in the Singleton class..
instance = new Singleton();
..but in the class MainApp I cannot instantiate a Singleton() instance?
Because the constructor is protected, so it's only accessible in the class itself and classes that inherit from the singleton class.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Once you are inside the class you can create an object of that class, even the constructor is private, in your case its protected. In MainApp you are not deriving that class, so for MainApp Singelton class in not visibile, as its constructor is protected.
Hope this helps you.
Imran
[MCTS]
Few have audacity to speak truth
|
|
|
|
|
The purpose of having a constructor that is not public, is that the class itself gets full control over the instances that is created.
The singleton pattern is used when you only want a single instance of the class. The constructor is non-public, so that only the class itself can create instances. That way you have to call the Instance method to get an instance, and it will only create a new instance the first time it's called.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
I need to view DataReader results in WinForms application for quick debug.
I tried code below but DataGridView is empty.
How to fix ?
using System.Data;
using System.Windows.Forms;
using Npgsql;
class Form1 : Form
{
static void Main()
{
Application.Run(new Form1());
}
DataGridView dataGridView1 = new DataGridView();
Form1()
{
string s = "SERVER=localhost;USER=postgres";
string query = @"select * from pg_tables";
var con1 = new NpgsqlConnection(s);
IDbCommand cmd = con1.CreateCommand();
cmd.CommandText = query;
con1.Open();
var dr = cmd.ExecuteReader();
dataGridView1.DataSource = dr;
Controls.Add(this.dataGridView1);
}
}
Andrus
|
|
|
|
|
you missed DataBind method() ???
Imran
[MCTS]
Few have audacity to speak truth
|
|
|
|
|
This is Winforms. DataGridView does not have Databind method.
If I assign IList<> to DataSource, DataGridView shows data withtout Databind method.
So I think I havent missed it.
Andrus
|
|
|
|
|
I am using HttpWebRequest object for communicating with a Sun Java System Web Server. The behaviour of the Server is very random. For the same requests, sometimes I get the response and sometimes I get Internal Server Error 500.
This is a third party server which reportedly works fine with other client applications so it seems there is a problem with my code. The code is simply using HttpWebRequest and HttpWebResponse objects to massage requests and responses.
I am re-initializing the HttpWebRequest object for each new request, the reason being the fact that I cannot reassign request.ContentLength to a value once the request has begun.
Any clues?
|
|
|
|
|
You haven't supplied a lot to go on here. Without seeing the code, it's going to be difficult to diagnose what issues you are having.
|
|
|
|
|
Hi,
I am trying to connect to IPCChannel using an impersonated user and had encountered an Access Denied exception. Have anyone encountered this? Please help.
Please see some code snippets below:
Server:
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
System.Collections.IDictionary props = new System.Collections.Hashtable();
props["portName"] = "TestRemoteObject";
props["name"] = "TestRemoteObject";
props["authorizedGroup"] = "Everyone";
props["impersonate"] = true;
props["secure"] = true;
serverChannel = new IpcServerChannel(props, serverProvider);
ChannelServices.RegisterChannel(serverChannel, true);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject), "TestRemoteObject", WellKnownObjectMode.Singleton);
Client:
BinaryClientFormatterSinkProvider clientSink = new BinaryClientFormatterSinkProvider();
System.Collections.IDictionary clientProps = new System.Collections.Hashtable();
clientProps["secure"] = true;
clientProps["tokenImpersonationLevel"] = TokenImpersonationLevel.Delegation;
IpcClientChannel clientChannel = new IpcClientChannel(clientProps, clientSink);
ChannelServices.RegisterChannel(clientChannel, true);
// Impersonate user to use Administrator
IntPtr token;
bool result = LogonUser(
"Administrator", "MyMachine",
"MyPassword",
LogonTypes.Network,
LogonProviders.Default,
out token);
if (result)
{
WindowsIdentity identity = new WindowsIdentity(token);
using (WindowsImpersonationContext imp = identity.Impersonate())
{
try
{
RemoteObject remote = (RemoteObject)Activator.GetObject(typeof(RemoteObject), "ipc://TestRemoteObject/TestRemoteObject");
message = remote.Echo("Test");
}
catch (Exception exc)
{
message = exc.ToString();
}
imp.Undo();
}
MessageBox.Show(message);
CloseHandle(token);
}
Error Message:
System.Runtime.Remoting.RemotingException: Failed to connect to an IPC Port: Access is denied.
Server stack trace:
at System.Runtime.Remoting.Channels.Ipc.IpcPort.Connect(String portName, Boolean secure, TokenImpersonationLevel impersonationLevel, Int32 timeout)
at System.Runtime.Remoting.Channels.Ipc.ConnectionCache.GetConnection(String portName, Boolean secure, TokenImpersonationLevel level, Int32 timeout)
at System.Runtime.Remoting.Channels.Ipc.IpcClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
If I tried to run client application using the administrator account, then connect without impersonating, it works fine. However, if I am doing impersonation it fails. Hope to get some help. Thanks in advance.
SDE
|
|
|
|
|
You are running the server and client on the same machine, right?
|
|
|
|
|
Yes.
I was wondering why it doesn't allow me to instantiate a remoting object, when I'm running on an impersonated account.
SDE
|
|
|
|
|
Hi all,
I am struggling with a problem. Please some one suggest me to get out of that. I am working with a existing website developed by some other developer long back. I that he stores the images using name genearated by Guid.NewGuid(), the name of the picture in the folder is difference with this name in database.
Now I have to develop a service to delete the images older than 15 days. My problem is i am retrieving the filename from database, but that file name is not equal to the file name in folder.
I dnt knw why he used Guid.NewGuid(), can any one please tell me what is the use and advantage of Guid.NewGuid() , also how to solve my issue.
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
Exelioindia wrote: Guid.NewGuid(),
It generates a unique GUID.
Exelioindia wrote: Now I have to develop a service to delete the images older than 15 days. My problem is i am retrieving the filename from database, but that file name is not equal to the file name in folder.
Then you can check the file's creation date and if it is more than 15 days, delete it.
|
|
|
|
|
Yor are correct, but along with that i am checking for some other conditions also in database
Thanks for you reply
Know is Drop, Unknown is Ocean
|
|
|
|
|
Exelioindia wrote: I dnt knw why he used Guid.NewGuid(), can any one please tell me what is the use and advantage of Guid.NewGuid()
This is a common design to get round name collision issues. Basically, you can have two files called Document1.doc from different users - you can only store one of these in a directory, so you need to generate a unique name and associate this with the document. In other words, you rename the file from Document1.doc to your guid named file and you have a mapping in the database that shows the original filename and the new filename.
|
|
|
|
|
hi to all,
i published a website using solutionexplorer in asp.net 2.0 and usually i get the published folder containing the files but today i m unable to get the folder with files after publishing it is giving publish succeeded but there are no files in it how to resolve this problem i m using vss version 6.0 and all folders are checkedin
sai krishna
|
|
|
|
|
First of all it is not a C# question. You must post questions in the appropriate forums.
Solution: When you click on publish it must have asked you for the path. Try changing the path. And then copy the path and see that do the files exist after publishing.
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
Well, I didn't know where should I ask my question, so I ask it here!
I'm willing to know what exactly happened (for OS and whom it may concern!) when a running application calls a function or a sub or a method?
And is there any way to get the name of that function or sub or method?
Thanks.
|
|
|
|
|
pm526467 wrote: I'm willing to know what exactly happened (for OS and whom it may concern!) when a running application calls a function or a sub or a method?
Usually the function's (or sub's or method's) code is executed.
pm526467 wrote: And is there any way to get the name of that function or sub or method?
Of course.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[Image resize DLL]
|
|
|
|
|
Oh! Thank you very much dear CPallini! That was really helpfull!
Would you mind telling me HOW can I get those name (in C# of course)?
|
|
|
|
|
hi there... I have one problem, and I cannot solve, so any help will be appreciated. I have a datagridview control on a windows form. I am using the form for retrieving data from a local database, and then cleaning up the selected data. So I want to add a checkbox column, when the user will check the checkbox, that would mean that the row is selected, and he can delete just the checked rows. How I can do that, any help? Thx
|
|
|
|