|
Member 2458467 wrote: A generic error occurred in GDI+. Well, those GDI errors generally come with useless information. The issue could be far simpler than you think: e.g. missing privileges to write the file.
Otherwise, make sure that .Net Framework version 2 is installed, and maybe you need some settings that that version is taken despite version 4 being available on the Win 7 machine.
|
|
|
|
|
I also do not know the cause of this error, all the related applications I installed on winxp how I install on win7 like that, I also installed Net 2.0 but still the error on. In win7 I do not troubleshoot (debug) This program when pressing the F11 key. Do you have any way to debug this program ?
|
|
|
|
|
There are tools for Remote Debugging: e.g. the Visual Studio Remote Debugger. But I am not sure if a version suitable for Visual Studio 2005 is available for Windows 7.
|
|
|
|
|
|
Good night, I am trying to work the Devart Entity Developers ORM with Visual Studio C #, but I have not found many examples or documentation, they could help me to realize this implementation or development that I need.
Thanks in advance
A.M
|
|
|
|
|
As a professional developer, I find that one of the greatest skills at my disposal is knowing how to put together a query in Google. By typing devart entity framework tutorial into Google, I managed to find this list[^].
This space for rent
|
|
|
|
|
I Have two different sessions timeout, work different for different users.
Web.Config file:
<authentication mode="Forms">
<forms defaultUrl="~/default.aspx" loginUrl="~/login.aspx" slidingExpiration="true" />
</authentication>
<appSettings>
<add key="AdminUser" value ="120"/>
<add key="OtherUser" value ="15"/>
</appSettings>
Main.Master.cs
if(LoggedInUser=="Admin")
{
Session.Timeout = Convert.ToInt32(ConfigurationManager.AppSettings.Get("AdminUser"));
}
else
{
Session.Timeout = Convert.ToInt32(ConfigurationManager.AppSettings.Get("OtherUser"));
}
Everything works well with local and test server but after web deployment, Started facing issue of early logout after 30 Minutes for admin User,when site is idle for 30 min and tried to access again ,its been redirected to login page. Verified by changing session value in IIS, still issue remains same. Kindly suggest.
|
|
|
|
|
Check your hosting service: many apply a session limit and will ignore any attempt to extend it beyond that point. (Some of the cheaper ones will also reduce it from the default twenty minutes to five or so and refuse to extend beyond that.)
Do note that it is not recommended to extend the Session above the default twenty minutes as each session occupies server memory.
I'd also be worried about extending the session for someone with extra powers: this creates a greater security risk.
If you need longer persistence of data, then perhaps you should be considering Cookies instead of Session variables?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Why have ICloneable been made?
Let's see the below test source. The outcome would turn out quite different from what we have expected.
So, we need DeepClone. but, non-serializable object needs some methods
(refer to this: A Generic Method for Deep Cloning in C# 3.0[^] ).
class Program
{
static void Main(string[] args)
{
MyClass c1 = new MyClass();
c1.Name = "Name1";
c1.Value = "Value1";
MyClass c2 = c1.Clone();
c2.Name = "Name2";
c2.Value = "Value2";
c2.Lists.Add("D");
<pre>
Console.WriteLine(c1.ToString());
Console.WriteLine(c2.ToString());
Console.ReadLine();
}
}
public class MyClass: ICloneable
{
public string Name { get; set; }
public string Value { get; set; }
public List<string> Lists = new List<string>() { "A", "B", "C" };
public MyClass()
{
}
public MyClass(MyClass c)
{
Name = c.Name;
Value = c.Value;
Lists = c.Lists;
}
public MyClass Clone()
{
return this.MemberwiseClone() as MyClass;
}
object ICloneable.Clone()
{
return this.MemberwiseClone();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Name={0}, ", Name);
sb.AppendFormat("Value={0}, ", Value);
sb.Append("Lists=");
bool b = false;
foreach (var item in Lists)
{
if (b)
sb.AppendFormat("|{0}", item);
else
sb.AppendFormat("{0}", item); b = true;
}
return sb.ToString();
}
}</pre>
Brad
You go, we go~.
|
|
|
|
|
And what is the question you want answering?
This space for rent
|
|
|
|
|
I didn't make a question.
I just would like to arrange that WeakClone has some problem and Why DeepClone needs.
Brad
You go, we go~.
|
|
|
|
|
When you clone using Memberwise Clone, it creates a "shallow copy:" any internal fields in the cloned object that you don't set explicitly retain their value: for a cloned generic List that value is a reference: change that reference, and you change its value in any object that has a reference to it.
To make your code work: initialize the List in the MyClass constructor; and, in the Clone method initialize the cloned reference List. This is a bit tricky, and I suggest you spend some time carefully studying the examples here: [^]
public class MyClass : ICloneable
{
public string Name { get; set; }
public string Value { get; set; }
public List<string> Lists;
public MyClass()
{
Lists = new List<string>() { "A", "B", "C" };
}
public MyClass Clone()
{
var clone = this.MemberwiseClone() as MyClass;
clone.Lists = new List<string>();
return clone;
}
object ICloneable.Clone()
{
return this.MemberwiseClone();
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Name={0}, ", Name);
sb.AppendFormat("Value={0}, ", Value);
sb.Append("Lists=");
bool b = false;
foreach (var item in Lists)
{
if (b)
sb.AppendFormat("|{0}", item);
else
sb.AppendFormat("{0}", item); b = true;
}
return sb.ToString();
}
}
«Differences between Big-Endians, who broke eggs at the larger end, and Little-Endians gave rise to six rebellions: one Emperor lost his life, another his crown. The Lilliputian religion says an egg should be broken on the convenient end, which is now interpreted by the Lilliputians as the smaller end. Big-Endians gained favor in Blefuscu.» J. Swift, 'Gulliver's Travels,' 1726CE
|
|
|
|
|
Good Idea. Even WeakClone we could use safly without DeepClone.
Brad
You go, we go~.
|
|
|
|
|
The task of deep cloning a .NET object is the subject of numerous articles, and some open source libraries; techniques used include serialization, reflection, and some very esoteric stuff:
CP 2017: [^] this prize-winning article contains a good overview of the different possible techniques.
GitHub: [^] reflection, [^] serialization
cheers, Bill
«Differences between Big-Endians, who broke eggs at the larger end, and Little-Endians gave rise to six rebellions: one Emperor lost his life, another his crown. The Lilliputian religion says an egg should be broken on the convenient end, which is now interpreted by the Lilliputians as the smaller end. Big-Endians gained favor in Blefuscu.» J. Swift, 'Gulliver's Travels,' 1726CE
|
|
|
|
|
I am using VS 2015 with .Net framework 5.2.1 and winforms. The rich text box calls are making the application crash intermittently
with System.AccessViolationException:
At the bottom there is error from Event Viewer and it seems it is crashing while setting Selection start. I set Selection start at two
places in my code. The crash is intermittent. I will really appreciate any pointers.
1) While scrolling it to the bottom:
richTextBox1.SelectionStart = richTextBox1.Text.Length;
richTextBox1.ScrollToCaret();
2) while appending text to the richtextbox:
public static void AppendText(this RichTextBox box, string text, Color color)
{
box.SelectionStart = box.TextLength;
box.SelectionLength = 0;
box.SelectionColor = color;
box.AppendText(text);
}
EventViewer:
Application: AutomationHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.NativeWindow.DefWndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control.DefWndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.TextBoxBase.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.RichTextBox.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(System.Runtime.InteropServices.HandleRef, Int32, Int32, EDITSTREAM)
at System.Windows.Forms.RichTextBox.StreamOut(System.IO.Stream, Int32, Boolean)
at System.Windows.Forms.RichTextBox.StreamOut(Int32)
at System.Windows.Forms.RichTextBox.get_SelectedText()
at System.Windows.Forms.RichTextBox.get_SelectionLength()
at System.Windows.Forms.TextBoxBase.set_SelectionStart(Int32)
at AutomationHostHelper.Test.ThreadSafeRichTextBox()
Exception Info: System.Reflection.TargetInvocationException
at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
at System.Delegate.DynamicInvokeImpl(System.Object[])
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback,
System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object,
Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.TextBoxBase.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.RichTextBox.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
at System.Windows.Forms.Application
+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application.Run(System.Windows.Forms.Form)
at AutomationHost.Program.Main(System.String[])
|
|
|
|
|
public static void AppendText(this RichTextBox box, string text, Color color)
at AutomationHostHelper.Test.ThreadSafeRichTextBox() Are you calling those functions from a different thread?
Then that might be the reason. I don't know enough about thread safety of C# controls to help you but other's might know.
|
|
|
|
|
My host:
IP: 192.168.28.143
Mask: 255.255.254.0
Default gateway: 192.168.28.1
Target IP: 192.168.4.93
My IP and target IP are both working PC in my company.
I want get host name of target IP.
string name = Dns.GetHostEntry("192.168.4.93").HostName;
But it failed.
If I get same segment IP hostname, e.g.
string name = Dns.GetHostEntry("192.168.28.121").HostName;
It successfull.
My question is:
How to get host name of target IP successfull?
Use .Net method.
|
|
|
|
|
The only solution I know would be having the IP address of the local DNS server for the other segment (if there is any but it is usually on the gateway for that segment). Than you have to query that DNS server which requires a DNS client library that allows specifying the server(s) to be queried because the .NET Dns class uses only the servers from Windows configuration.
But even that might not work when denied by firewalls or your gateway has no route to the other network segment.
The problem is that all your addresses are local (reserved). Those can be only resolved by DNS when there is a DNS server for the local network segment. This is usually the gateway system (e.g. a router). There are also some fallback methods like the /etc/hosts file and SMB/CIFS name resolution with Windows. But those will work again only for the local network segment.
|
|
|
|
|
You need to talk to your SysAdmins and determine how DNS is provided within your environment. Until you know that you will be shooting in the dark.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
maybe this code will help
string ip = "192.168.1.5";
Ping myPing = new Ping();
PingReply reply = myPing.Send(ip);
if (reply.Status == IPStatus.Success)
{
try
{
IPAddress ipAddres = IPAddress.Parse(ip);
IPHostEntry host = Dns.GetHostEntry(ipAddres);
Console.WriteLine(host.HostName.ToString());
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
|
|
|
|
|
Hi all,
i am trying to expose C# object to COM and in this process i got a query and not sure how to progress further. so here i am seeking for help.
i want to define a interface in C# in such a way the consumer of the COM object should be able to use the method in the following way.
comObject.methodName(123)
the above statement will return a value, assume where 123 is the parameter which could id or some thing like that
comObject.methodName(123) = 100
the above statement should set the value 100 something internal member having id 123
in both the above statement the methodName is the same.
so the question is how can we define an interface in C# that can be exposed to COM using regasm.exe.
i know it is possible to define such a way in C++ using ATL but not sure how can i achieve the same in C#.
[Comvisible(true)]
interface ExposeToCom
{
// don't know what all to add to make the method appear to COM to be get and set
int methodName(int);
}
Thanks for your help,
|
|
|
|
|
|
You are use a method as if it was a property . You cannot assign a value to a function!
Rather think of comObject.methodName(123, 100) , i.e. a function with 2 parameters (key and value ).
|
|
|
|
|
Thanks for your response.
Actually, i am trying re-write a COM component developed in ATL which is production. i want to give the same interface so that consumer has minimal impact.
code snippet from my existence code.
STDMETHOD(get_methodA)( VARIANT storeID, VARIANT *pVal);
STDMETHOD(put_methodA)( VARIANT storeID, VARIANT newVal);
STDMETHOD(get_methodB)( VARIANT storeID, VARIANT index, VARIANT *pVal);
STDMETHOD(put_methodB)( VARIANT storeID, VARIANT index, VARIANT newVal);
when i extract the typelib for this
[id(0x00000001), propget, helpstring("property methodA")]
HRESULT methodA([in] VARIANT storeID, [out, retval] VARIANT* pVal);
[id(0x00000001), propput, helpstring("property methodA")]
HRESULT methodA([in] VARIANT storeID, [in] VARIANT pVal);
[id(0x00000004), propget, helpstring("property methodB")]
HRESULT methodB([in] VARIANT storeID, [in] VARIANT index, [out, retval] VARIANT* pVal);
[id(0x00000004), propput, helpstring("property methodB")]
HRESULT methodB([in] VARIANT storeID, [in] VARIANT index, [in] VARIANT pVal);
so the consumer can use as
methodA(123) -- return a value
methodA(123) = 100 -- this will set a value
methodB(123, 3) -- return a value
methodB(123, 3) = 100 -- this will set a value.
i am trying to mimic the same methods defined in my ATL in a C# interface and use .net com interoperability using a regasm.
i am not able to find out how achieve this in C#. if this is done in ATL i was thinking there could be a way to achieve this.
thanks for your time
modified 27-Jul-17 13:36pm.
|
|
|
|
|
If you have a type library, you can convert it into a .NET assembly using tlbimp.
This space for rent
|
|
|
|
|