|
Are the firewalls configured correctly?
|
|
|
|
|
Do you get any error message on why you can't connect?
|
|
|
|
|
Here is the error message:
A remote side security requirement was not fulfilled during authentication. Try increasing the Protection Level and/ or Impersonation Level
And firewall is off on both client and server
|
|
|
|
|
So on your proxy object - what kind of settings do you use on your binding?
|
|
|
|
|
Hi Calla, I solved the issue. Thanks for your interest
|
|
|
|
|
Great!
|
|
|
|
|
Hi,
i am trying to implement cache managing using Microsft enterprise library.
I want to fetch the physical path of my file saved in cache.
i tried with reflection like this
Stream dcmStream = (IsolatedStorageFileStream)cache["key"];
string fullPath = dcmStream.GetType().GetField("m_FullPath",
BindingFlags.NonPublic | BindingFlags.Instance).GetValue(dcmStream).ToString();
It is not working. Could you help me?
My small attempt...
|
|
|
|
|
"It is not working" does not tell what the problem is.
What is it doing wrong? Is there an error message, and what is it?
|
|
|
|
|
Why are you caching a stream rather than the file itself? Why do you need the physical path of something in Isolated Storage? Sounds like you are using the wrong tools for what you are trying to accomplish.
|
|
|
|
|
Hi.
I have a User Control and i added it to my Tool Box.When you add this control to your form, user control shows a form with 1 button.
I want to click the button and one Text Box be added on the Main Form(Form1).
How can get the form in that time(from my User Control)??
This is Design time!!
Thank you.
CanI
|
|
|
|
|
Repost!
Don't post in more than one place - all you do is duplicate work and annoy people. Either post in the forums, or in Q&A. But not both.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Sorry,My connection broke and i thought it wasn't saved.
CanI
|
|
|
|
|
Fair enough - I've upvoted your question to counter the one vote.
However, you can do away with the flowers in your question (if possible) though.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
i can not understand your question .
plz provide more details
|
|
|
|
|
Hi.
Let me tell you again.
I create a UserControl .OK!.
In Load event i write this:
<pre>
private void UserControl1_Load(object sender, EventArgs e)
{
//Add Form1 to your UserControl with one Button on(button 1) it.Think we did design it.
Form1 f1=new Form1();
f1.Show Dialog();
}
</pre>
And now in that button(f1.button1) write this:
<pre>
private void button1_Click(object sender, EventArgs e)
{
TextBox textBox= new TextBox();
textBox.Text="Name";
//And now work start.
//Now i want to get the Form that you add the<b> UserControl</b> on it,Got it??The Main Form that Contain the UserControl.
//Form1 or any other name
Form1 f1=new Form1();
f1.Controls.Add(textBox);
//
}
</pre>
The question is How to get that form and throw(Add) the textBox on it!!We don't have it now!!??What a code should we write?
I hope you understand what i am telling you.
Thank you.
CanI
|
|
|
|
|
i need few demos of get post methods that will logs into any website and retrieves data from there.
|
|
|
|
|
For one sample, see here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Sonu J wrote: i need few demos of get post methods that will logs into any website and retrieves data from there.
..and what's your question?
You can find demo's both on this site and Google. I'd suggest using a WebBrowser component, since that would simplify cookie-handling.
I are Troll
|
|
|
|
|
There are several examples of this to be found in articles at CodeProject, including this[^] framework to scrape data off a website using GET or POST .
/ravi
|
|
|
|
|
#region HttpPost
protected string HttpPost(string url_, string contents_, bool useCredentials_, NetworkCredential creds_)
{
bool isSuccess = false;
int noOfRetry = 0;
string response = string.Empty;
try
{
WriteToLog(string.Format("Starting HTTPPost Publishing message {0} \r\n {1}", url_, contents_));
while (!isSuccess && noOfRetry < m_noOfRetry)
{
WriteToLog("HTTPPost " + "Success Status :" + isSuccess.ToString() + " Retry Count: " + noOfRetry.ToString());
Uri url = new Uri(url_);
HttpWebRequest _webRequest = (HttpWebRequest)WebRequest.Create(url);
_webRequest.Timeout = 400000000;
_webRequest.Method = "POST";
_webRequest.ContentType = "text/xml; charset=ISO-8859-1";
_webRequest.KeepAlive = true;
_webRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
if (useCredentials_)
{
string password = string.Empty;
string username = string.Empty;
//if no credentails provided then use
if (creds_ == null)
{
password = ConfigurationManager.AppSettings["password"] == null ?
null : ConfigurationManager.AppSettings["password"].ToString();
username = ConfigurationManager.AppSettings["user"] == null ?
null : ConfigurationManager.AppSettings["user"].ToString();
if (password == null || username == null)
{
WriteToLog(SMSConstants.INCOMPLETE_SMSGATEWAY_INFORMATION);
throw new Exception(SMSConstants.INCOMPLETE_SMSGATEWAY_INFORMATION);
}
WriteToLog("Connecting using UserName :" + username);
password = GetDecString(password);
String userInfo = username + ":" + password;
byte[] bt = new byte[userInfo.Length];
bt = System.Text.Encoding.UTF8.GetBytes(userInfo);
string encodedData = Convert.ToBase64String(bt);
String authInfo = "Basic " + encodedData;
_webRequest.Headers.Set("Authorization", authInfo);
}
else
{
_webRequest.Credentials = creds_;
WriteToLog(String.Format("{0}{1}", "Connecting using provided User credentials UserName :", creds_.UserName));
}
}
try
{
Stream _stream = _webRequest.GetRequestStream();
StreamWriter _writer = new StreamWriter(_stream);
_writer.Write(contents_);
_writer.Close();
HttpWebResponse _webResponse = (HttpWebResponse)_webRequest.GetResponse();
_stream = _webResponse.GetResponseStream();
StreamReader _sReader = new StreamReader(_stream);
String _response = _sReader.ReadToEnd();
_sReader.Close();
response = _response;
//Underlying connection closed response NOT An EXCEPTION
if (response.IndexOf("The underlying connection was closed:") == -1)
{
isSuccess = true;
}
else
{
isSuccess = false;
Thread.Sleep(1000);
}
}
//Got exception for connection closed
catch (Exception exp_)
{
if (exp_.Message.IndexOf("The underlying connection was closed:") != -1)
{
WriteToLog(string.Format("The underlying connection was closed. retrying {0}", noOfRetry.ToString()), EventLogEntryType.Error);
isSuccess = false;
}
}
noOfRetry++;
}
WriteToLog("HTTPPost Published message successfully");
}
catch (Exception exp_)
{
response = exp_.Message + Environment.NewLine + exp_.StackTrace;
WriteToLog(string.Format("In Catch Block {0}", response), EventLogEntryType.Error);
}
return response;
}
#endregion //End-HttpPost
#region WriteToLog
/// <summary>
/// Writes a message to Event Log
/// </summary>
/// <param name="message_">message to log</param>
protected void WriteToLog(string message_)
{
WriteToLog(message_, EventLogEntryType.Information);
}
#endregion //End-WriteToLog
#region WriteToLog
/// <summary>
/// Writes a message to Event Log
/// </summary>
/// <param name="message_">message to log</param>
/// <param name="level_">Level to Log error</param>
protected void WriteToLog(string message_, EventLogEntryType level_)
{
try
{
object logConfig = ConfigurationManager.AppSettings["enablelogging"];
bool enableLogging = logConfig == null ? false : Convert.ToBoolean(logConfig.ToString());
Console.WriteLine(Environment.NewLine + message_);
if (enableLogging)
{
string CurrentDate = DateTime.Now.ToShortDateString().Replace("/", "-");
File.AppendAllText(Server.MapPath("Logs/Error_Log_" + CurrentDate),
string.Format("{0}{1} {2} {3}"
, Environment.NewLine
, CurrentDate
, DateTime.Now.ToLongTimeString()
, message_));
}
}
catch //(Exception exp_)
{
//throw exp_;
}
}
#endregion //End-WriteToLog
cheers
varun sharma
|
|
|
|
|
Hi!
There must be a smarter way to do this! This is about if I can bind a simple datastructure to a table.
Problem: I want to hold an instance of a (simple) datastructure - say a List<t> or a Collection or similar - I don't care - representing the contents of a view or table - say view. How to impl. that the most natural/generic way?
My solution:
// Fill DataTable.
DataTable dt = new DataTable();
string strConn = "Data Source=MyPC\\SQLExpress; Initial Catalog=MyDBInst; Integrated Security=True; User ID=; Password=;";
SqlConnection con = new SqlConnection(strConn);
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM v_SomeViewOfMine", con);
da.Fill(dt);
// Populate List.
List<testclass> my_list = new List<testclass>();
foreach(DataRow dr in dt.Rows)
my_list.Add(new TestClass(
(string)dr.ItemArray[0],
(int)dr.ItemArray[1],
(int)dr.ItemArray[2],
(int)dr.ItemArray[3]));
con.Close();
Where constructor TestClass is:
public TestClass(string s, int a, int b, int c)
{ Name = s; Category = a; Conference = b; SubCategory = c; }
This approch works - "all is fine" and list is fine! Or is it? I feel that I miss some binding michanism-thingy like (pseudo):
List<testclass> my_list = new List<testclass>();
my_list.BindToDataTable(dt);
my_list.SetBindingColumn("Name", "Name", Type.string);
my_list.SetBindingColumn("Category", "Category", Type.int);
my_list.SetBindingColumn("Conference", "Conference", Type.int);
my_list.SetBindingColumn("Sub category", "SubCategory", Type.int);
Inspired from how one would setup a DataGrid in a xaml (< DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" />).
So in other words: Do I have to iterate the DataTable myself (dealing with dr.ItemArray[] typed object) or can I bind it to a datastructure in some way?
Thank's in advance.
Michael Mogensen
modified on Saturday, October 30, 2010 8:56 PM
|
|
|
|
|
You can do something like this instead of looping throught the dataset/SqlDataAdapter. First you can create a class that inherits DataContext. And then you can use methods of DataContext like to ExecuteQuery<> to convert your results in to objects. With this method you can directly use your queries you wrote earlier.
Consider the following example. First you need to define a class for interacting with your database
public class DBManagerDataContext : DataContext
{
private static string connectionString = "";
public static DBManagerDataContext CreateInstance()
{
return new DBManagerDataContext(connectionString);
}
protected DBManagerDataContext(string connectionString)
: base(connectionString, new AttributeMappingSource())
{
}
}
Then you can use this context to execute queries and convert them in to objects as shown below:
public class Report
{
public int ReportID;
public string ReportTitle;
public DateTime ReportDate;
private static string query = "select ReportID, ReportTitle, ReportDate from dbo.Reports";
public static List<Report> GetReportList()
{
DBManagerDataContext context = DBManagerDataContext.CreateInstance();
return context.ExecuteQuery<Report>(query).ToList();
}
}
You can use the method "GetReportList()" given above like this for example:
List<Report> reports = Report.GetReportList();
Please note that the query column names should match the definition in the object
This is just an example. You could do something like this, that would serve your purpose.
I guess this is what you are asking about...
Cheers,
Karthik
|
|
|
|
|
I have a program developed in C#. The form's WindowState property is set to Maximized, but when i change the resolution than the window doesn't fits on the screen.
Any ideas, what to do so that whatever the resolution is windows adjusts accordingly
|
|
|
|
|
Oh boy!
You will have to work on that. It's not a trivial problem, the best advice I can give is to suggest you start here: MSDN Automatic scaling in Windows Forms[^]
You may find that by using Panels and following the article you may be able to do it. But it would be better to re-design your app so you don't have a single, really busy, form...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Or to use WPF - defining xaml's without any width/height information is just SO possible in WPF, making all windows fit to any screen or device.
Michael Mogensen
|
|
|
|