Quantcast
Channel: Visual C# forum
Viewing all 31927 articles
Browse latest View live

Slow .exe Performance

$
0
0

I have an application that runs very slowly when ran from the .exe 

The Performance is 10 times better when i run it from within visual studio.

What could be the cause of this?

The Application itself parses through records in a binary file.


C#: Cannot convert type 'ConnectionManager.SQLLocalConnection' to 'System.Data.SqlClient.SqlConnection

$
0
0

this code is not working

SqlConnection conn1 = (SqlConnection) ConnectionManager.Factory.BBADBConnectionFactory.GetGenericConnection<BBASQLLocalConnection>(ConnectionType.LocalSQLConnection);

rather throwing error like Cannot convert type 'ConnectionManager.SQLLocalConnection' to 'System.Data.SqlClient.SqlConnection

this way i am returning connection.

publicstatic T GetGenericConnection<T>(ConnectionTypeConnectionFor){if(ConnectionFor==ConnectionType.LocalSQLConnection)return(T)Convert.ChangeType((newSQLLocalConnection()).Connection,typeof(T));elseif(ConnectionFor==ConnectionType.ORCSWEBSQLConnection)return(T)Convert.ChangeType((newORCSSQLConnection()).Connection,typeof(T));elseif(ConnectionFor==ConnectionType.ReportConnection)return(T)Convert.ChangeType((newSQLReportConnection()).Connection,typeof(T));elsereturn(T)Convert.ChangeType((newSAGEConnection()).Connection,typeof(T));}

one sample connection class

publicsealedclassSQLLocalConnection{SqlConnection sqlCon;publicSQLLocalConnection(){string connectionString =DBConnectionFactory.GetDBConnectionString<DBConnectionString>(DBCommon.SQLCredentialLocal).ToString();
            sqlCon =newSqlConnection(connectionString);}publicSqlConnectionConnection{
            get{return sqlCon;}}}

Stop Looping for playing sound

$
0
0

Hy friend,

I have a problem 

I just create a form for playing sound, her's my code

 public partial class Form1 : Form
    {
        System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Sound.wav");

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Interval = 3*1000; 
            this.ShowInTaskbar = false;
            this.ControlBox = false; 
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = "Test";
            player.Play();
            
        }

    }

the problem is the sounds always Looping, what I want is this sound just play once

and also I want to change the path of the sound (not always in C:\ directory)

Does anyone can help me ??

Thank You :)

Regards,

Steve Henry

difference between factory and abstract factory

$
0
0
please show me with a example code that what is difference between factory and abstract factory. thanks

How to handle ObjectDisposedException in C#?

$
0
0
I am using the "Minitab 17" COM component in my C# application. My application suddenly crashes with "System.ObjectDisposedException was unhandled" error message.  I am unable to identify exact root cause, but I have observed that if I don't use the COM component, I don't see the error.

The stack call trace is showing this error messsage:

System.ObjectDisposedException was unhandled
  HResult=-2146232798
  Message=Safe handle has been closed
  Source=mscorlib
  ObjectName=""
  StackTrace:
       at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
       at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
       at Microsoft.Win32.UnsafeNativeMethods.GetOverlappedResult(SafeFileHandle hFile, NativeOverlapped* lpOverlapped, Int32& lpNumberOfBytesTransferred, Boolean bWait)
       at System.IO.Ports.SerialStream.EventLoopRunner.WaitForCommEvent()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


I have `ReportWindow.xaml` file in WPF Project of name "AutomationProject"; it contains one button, with this `click` action:

    click
    {
    int x= Convert.ToInt32(cmbx.SelectedValue);
    int y= Convert.ToInt32(cmby.SelectedValue);           
    string validationmsg = validation();
    if (string.IsNullOrEmpty(validationmsg))
    {
                  
    if x!= 0 && y!= 0)
    {
     CompatibilityID = DataLayer.GetCompatibiltyTestI(x,y);
     CTDocumentWriter.WriteReportDoc(CompatibilityID);->Here CTDocumentWriter is a class from project name "Compatibility" as shown below.
       
    }
    }
    

    public static void WriteReportDoc(int nCompatibilityTestId)
        {
                       
           Utility.MiniTab.CreateMiniTabInstance();Here Utility.MiniTab is a class from project name "Utility" as shown below

                Dictionary<string, string> dic = new Dictionary<string, string>();
                dicToleranceInt.Add("a", "a1");
                dicToleranceInt.Add("b", "b1");

                foreach (KeyValuePair<string, string> entry in dic)
                {
                    Bitmap tol =
                    Utility.MiniTab.GetToleranceIntervalPlot(nCompatibilityTestId, entry.Value);
                    Image[] insertImgs = { tol_IntervalPlot };
                    string[] tags = { entry.Key };
                    Int64[] imgWidth = { 7000000L };
                    Int64[] imgHeight = { 7000000L };
                    SearchAndReplacer.InsertImageToDoc(sPath, insertImgs, tags, imgWidth, imgHeight);
                }

               Utility.MiniTab.Dispose();

        }    

       }

`Minitab.cs` class  is:

    public class MiniTab
    {
        private static Mtb.Application MtbApp = null;
        private static Mtb.Project MtbProject = null;
        private static Mtb.Worksheet MtbWorksheet = null;

        public static void CreateMiniTabInstance()
        {
            if (MtbApp == null)
            {
                MtbApp = new Mtb.Application();
                MtbProject = MtbApp.ActiveProject;
                MtbWorksheet = MtbProject.ActiveWorksheet;
                MtbApp.UserInterface.Visible = false;
                MtbApp.UserInterface.DisplayAlerts = false;
            }
        }

        public static string P_Value { set; get; }

        private static Image MiniTabCommandExecution(string command, bool IsGraphCmd, DataAccessLayer.Constants.MinitabCommandType cmdType)
        {
            Image graphImage = null;
            try
            {

                MtbProject.ExecuteCommand(command);
                if (IsGraphCmd)
                {
                    for (int i = 1; i <= MtbProject.Commands.Count; i++)
                    {
                        for (int j = 1; j <= MtbProject.Commands.Item(i).Outputs.Count; j++)
                        {
                            if (MtbProject.Commands.Item(i).Outputs.Item(j).OutputType == Mtb.MtbOutputTypes.OTGraph)
                            {
                                MtbProject.Commands.Item(i).Outputs.Item(j).Graph.CopyToClipboard();
                                graphImage = System.Windows.Forms.Clipboard.GetImage();
                                //  System.Windows.Forms.Clipboard.Clear();
                            }
                        }
                    }
                    if (cmdType == DataAccessLayer.Constants.MinitabCommandType.NormalProbability)
                    {
                        if (MtbWorksheet.Columns != null && MtbWorksheet.Columns.Item(5) != null && MtbWorksheet.Columns.Item(5).GetData(1, 1) != null)
                            P_Value = MtbWorksheet.Columns.Item(5).GetData(1, 1);
                    }

                }

                while (MtbProject.Commands.Count > 0)
                {
                    MtbProject.Commands.Remove(1);
                }
            }
            
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
          
            return graphImage;
        }

        public static void Dispose()
        {
            MtbApp.Quit();
            System.Diagnostics.Process[] proc = System.Diagnostics.Process.GetProcessesByName("Mtb");
           proc[0].Kill();
            
        }

        public static void ExportDt(DataTable dt)
        {
            try
            {
                //Stream myStream;
                //SaveFileDialog saveFileDialog1 = new SaveFileDialog();

                //saveFileDialog1.Filter = "Excel Workbook|*.csv";    //|(*.xls)";// *.txt|All files (*.*)|*.*";
                //saveFileDialog1.FilterIndex = 2;
                //saveFileDialog1.RestoreDirectory = true;

                //if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                //{
                //    if ((myStream = saveFileDialog1.OpenFile()) != null)
                {
                    // Code to write the stream goes here.
                    // string path = saveFileDialog1.FileName;
                    string path = ConfigurationManager.AppSettings["DataSheetVMinMax"].ToString();
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                    //myStream.Close();
                    if (dt.Rows.Count > 0)
                    {
                        //string pathTosaveCsv = Microsoft.ApplicationBlocks.ConfigurationManagement.ConfigurationManager.PathtoSaveCSV;
                        //string path = pathTosaveCsv + "UnpaidClaims.csv";
                        string strValue = string.Empty;
                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            if (!string.IsNullOrEmpty(strValue))
                            {
                                strValue = strValue + "," + dt.Columns[i].ToString();
                            }
                            else
                            {
                                strValue = dt.Columns[i].ToString();
                            }
                        }
                        strValue = strValue + Environment.NewLine;

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            for (int j = 0; j < dt.Columns.Count; j++)
                            {
                                if (j > 0)
                                {
                                    strValue = strValue + "," + dt.Rows[i][j].ToString().Replace(",", ";");
                                }
                                else
                                {
                                    strValue = strValue + dt.Rows[i][j].ToString().Replace(",", ";");
                                }
                            }
                            strValue = strValue + Environment.NewLine;
                        }
                        System.IO.File.WriteAllText(path, strValue);
                    }
                }
              
            }
            catch (Exception objex)
            {
                throw objex;
            }
        }

      
        public static string GetCommand(DataAccessLayer.Constants.MinitabCommandType cmdType, string columnName, string title, DoseAccuracyGraphData graphData)
        {
            string command = string.Empty;
            StringBuilder sb = new StringBuilder();
            try
            {
                switch (cmdType)
                {
                    case DataAccessLayer.Constants.MinitabCommandType.ToleranceInterval:

                        sb.Append("TolInterval '");
                        sb.Append(columnName);
                        sb.Append("'; GTIPlot; Confidence 95.0; PPercent 97.5.");
                        break;

                    case DataAccessLayer.Constants.MinitabCommandType.Histogram:

                        sb.Append("Histogram '");
                        sb.Append(columnName);
                        sb.Append("';Reference 1 ");
                        sb.Append(graphData.UL_Lab);
                        sb.Append(";Color 74;  Size 3; Angle 90;  TCOLOR 74;");//Color 74 is blue
                        sb.Append("Reference 1 ");
                        sb.Append(graphData.LL_Lab);
                        sb.Append(";Color 74;  Size 3; Angle 90;  TCOLOR 74;");
                        sb.Append("Reference 1 ");
                        sb.Append(graphData.Target);
                        sb.Append(";Color 25;  Size 3; Angle 90;  TCOLOR 25;");//Color 25 is red
                        sb.Append("Reference 1 ");
                        sb.Append(graphData.LL_Protocal);
                        sb.Append(";Color 50;  Size 3; Angle 90;  TCOLOR 50;");//Color 50 is green
                        sb.Append("Reference 1 ");
                        sb.Append(graphData.UL_Protocal);
                        sb.Append(";Color 50;  Size 3; Angle 90;  TCOLOR 50;  Title \"");//Color 50 is green
                        sb.Append(title);
                        sb.Append(" Tolerance Interval Plot for ");
                        sb.Append(columnName);
                        sb.Append("\";  SubTitle \"95% Tolerance Interval\"; SubTitle \"Atleast 97.5% of population covered\";  Bar.");
                        break;
                    case DataAccessLayer.Constants.MinitabCommandType.NormalProbability:
                        sb.Append("NormTest '");
                        sb.Append(columnName);
                        sb.Append("'; Title \"\";  SPVALUE C5.");
                        break;

                }
                command = sb.ToString();
            }
            catch (Exception ex)
            {
            }
            return command;
        }

        public static Bitmap Crop(Bitmap bitmap, Rectangle rect)
        {
            Bitmap croppedBitmap = null;
            try
            {
                // create new bitmap with desired size and same pixel format
                croppedBitmap = new Bitmap(rect.Width, rect.Height, bitmap.PixelFormat);

                // create Graphics "wrapper" to draw into our new bitmap
                // "using" guarantees a call to gfx.Dispose()
                using (Graphics gfx = Graphics.FromImage(croppedBitmap))
                {
                    // draw the wanted part of the original bitmap into the new bitmap
                    gfx.DrawImage(bitmap, 0, 0, rect, GraphicsUnit.Pixel);
                }
            }
            catch (Exception ex)
            {
            }

            return croppedBitmap;
        }

        public static Bitmap GetToleranceIntervalPlot(int nCompatibilityTestId, string Vmin_or_Vmax, BussinessEntity.ReportEditFields objReportEditFileds)
        {
            Bitmap groupImage = null;
            try
            {


                string OpenCsvFileCommand = "Wopen " + "\"" + ConfigurationManager.AppSettings["DataSheetVMinMax"].ToString() + "\"" + "; FType; CSV; DecSep; Period; Field; Comma; TDelimiter; DoubleQuote.";

                MiniTabCommandExecution(OpenCsvFileCommand, false, 0);

                //Normal probability graph
                string normalTest_Cmd = GetCommand(Constants.MinitabCommandType.NormalProbability, Vmin_or_Vmax, " ", null);
                //executes command and get the pvalue to decide whether a parametric or non parametric 
                Image normalTest = MiniTabCommandExecution(normalTest_Cmd, true, Constants.MinitabCommandType.NormalProbability);
                double pvalue;
                if (P_Value.ToString().Contains("<"))
                    pvalue = Convert.ToDouble(P_Value.Replace('<', ' ').Trim());
                else
                    pvalue = Convert.ToDouble(P_Value);
                //Tolerance Interval plot 
                string tolInt_Cmd =
                         GetCommand(Constants.MinitabCommandType.ToleranceInterval, Vmin_or_Vmax, " ", null);
                //executes command and get the tolerance  intval  plot
                Image imgTolInt =
                MiniTabCommandExecution(tolInt_Cmd, true, Constants.MinitabCommandType.ToleranceInterval);

                if (imgTolInt != null)
                {
                    ////crop the above toler interval image to get the interval plot alone
                    Bitmap croppedIntervalPlot = Crop(new Bitmap(imgTolInt), new Rectangle(20, 160, 430, 90));

                    Bitmap cropTable;
                    string ToleranceType = string.Empty;
                    if (pvalue > 0.05)
                    {
                        ToleranceType = "Normal";
                        cropTable = Crop(new Bitmap(imgTolInt), new Rectangle(460, 128, 110, 49));
                    }
                    else
                    {
                        ToleranceType = "Non Parametric";
                        cropTable = Crop(new Bitmap(imgTolInt), new Rectangle(460, 178, 110, 49));
                    }


                    ////Histogram plot 
                    string histogram_Cmd = GetCommand(Constants.MinitabCommandType.Histogram, Vmin_or_Vmax, ToleranceType, VminRefLinesData);
                    ////executes command and get histogram plot
                    Image imgHistogram =
                    MiniTabCommandExecution(histogram_Cmd, true, Constants.MinitabCommandType.Histogram);

                    Image[] imageNames = { imgHistogram, croppedIntervalPlot, cropTable, normalTest };
                    groupImage = new Bitmap(800, 1250);
                    using (Graphics g = Graphics.FromImage(groupImage))
                    {
                        System.Drawing.Color colour = ColorTranslator.FromHtml("#E5E5E5");
                        g.Clear(colour);
                        for (int i = 0; i < imageNames.Count(); i++)
                        {
                            System.Drawing.Size newSize = new System.Drawing.Size((int)(imageNames[i].Width * 1.4), (int)(imageNames[i].Height * 1.4));
                            using (Bitmap img = new Bitmap(imageNames[i], newSize))
                            {
                                switch (i)
                                {
                                    //Histogram graph
                                    case 0:
                                        g.DrawImage(img, new System.Drawing.Point(0, 0));
                                        break;
                                    //Interval Plot
                                    case 1:
                                        System.Drawing.Size newSize1 = new System.Drawing.Size((int)(imageNames[i].Width * 1.4), (int)(imageNames[i].Height * 1.8));
                                        using (Bitmap img1 = new Bitmap(imageNames[i], newSize1))
                                        {
                                            g.DrawImage(img1, new System.Drawing.Point(0, 540));
                                        }
                                        break;
                                    //Statistical Table (Normal or Non parametric)
                                    case 2:
                                        g.DrawImage(img, new System.Drawing.Point(600, 570));
                                        break;
                                    //Normal probability plot
                                    case 3:
                                        g.DrawImage(img, new System.Drawing.Point(0, 720));
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
               
            }
            return groupImage;
        }
    }

Padma Yeddula

Trying to save image into a folder. ERROR: A GENERIC ERROR OCCURS IN GDI+

$
0
0
 

When I added if (System.IO.File.Exists(fileName)) to the method where SaveToFolder is called, the codes inside the method was totally skipped. I do not have to check System.IO.File.Exists(fileName) anyway.

private void SaveToFolder(Image img, string fileName, string extension, Size newSize, string pathToSave)
        {
            // Get new resolution
            Size imgSize = NewImageSize(img.Size, newSize);
            using (System.Drawing.Image newImg = new Bitmap(img, imgSize.Width, imgSize.Height))
            {
                using (MemoryStream MS = new MemoryStream())
                  {
                newImg.Save(Server.MapPath(pathToSave), img.RawFormat); //A GENERIC ERROR OCCURS IN GDI+
                    }
             }
        }
        public Size NewImageSize(Size imageSize, Size newSize)
        {
            Size finalSize;
            double tempval;
            if (imageSize.Height > newSize.Height || imageSize.Width > newSize.Width)
            {
                if (imageSize.Height > imageSize.Width)
                    tempval = newSize.Height / (imageSize.Height * 1.0);
                else
                    tempval = newSize.Width / (imageSize.Width * 1.0);
                finalSize = new Size((int)(tempval * imageSize.Width), (int)(tempval * imageSize.Height));
            }
            else
                finalSize = imageSize; // image is already small size
            return finalSize;
        }
    }

How to change bolded date font color for a MonthCalendar ?

$
0
0
 

   Can anyone tell me if it is possible to change  bolded date font color for a MonthCalendar ?

   And how to do that ?

Thanks.

Connection timeout issue with .NET Framework 4.6.1 - Please help

$
0
0

Dear All,

We have a Development Environment of Visual Studio 2013 on Windows 8.1 for Winforms Application development which connects to remote MS SQL Server databases.

All were going fine until we installed Visual Studio 2015 recently along with Visual Studio 2013.

After installing .NET Framework 4.6.1, we are having issue connecting to the remote SQL database as stated in the MSDN blog https://blogs.msdn.microsoft.com/dataaccesstechnologies/2016/05/07/connection-timeout-issue-with-net-framework-4-6-1-transparentnetworkipresolution/.

Now we are in a position where we are UNABLE to use the parameter TransparentNetworkIPResolution because the database connection to the database is happending through another 3rd party API which expects just the primary database details like data source and its credentials.

Is there any other way by which we can override or set the value of TransparentNetworkIPResolution to false in the development environment?

Thanks in advance and any help is highly appreciated.

WIth Warm Regards,

Sujan



c# what is Cohesion and coupling

$
0
0
any one can explain it with example that what is Cohesion and coupling and what is difference between them. thanks

c# what is Cohesion and coupling

$
0
0
any one can explain it with example that what is Cohesion and coupling and what is difference between them. thanks

c# what is Cohesion and coupling

$
0
0
any one can explain it with example that what is Cohesion and coupling and what is difference between them. thanks

What are the differences between SockerServer and StreamSocketListener

$
0
0

Hi, New to this forum. If the above does not belong to this forum, please kindly move to the correct one. Thanks

I want to build a socket App.

For the server side :

1)  what are the differences between SocketServer and  StreamSocketListener?

2) I am using Visual Studio 2015 community version, which one should I use ? SocketServer or StreamSocketListener?

3) I want Asynchronous type socket for the server side

For client side :

Does it matter which client to work with SocketServer or StreamSocketListener ? say the client are iOS and Android?

Thanks




what is factory design pattern

$
0
0
please help me to understand what is factory design pattern with example. thanks

Email sender

$
0
0

Hello to everyone I google email sender and found something but I have promblem with smtp:

Code:

private void button1_Click(object sender, EventArgs e)
        {
            MailMessage mail = new MailMessage(textBox1.Text, textBox2.Text, textBox6.Text, textBox7.Text);
            SmtpClient client = new SmtpClient(textBox3.Text);
            client.Port = 587;
            client.Credentials = new System.Net.NetworkCredential(textBox4.Text, textBox5.Text);
            client.EnableSsl = true;
            client.Send(mail);
            MessageBox.Show("Mail Sent!", "Success", MessageBoxButtons.OK);
        }

and I have problem here:

client.Send(mail);

Icon:

Google smtp server is smtp.google.com but when I try it (with gmail of course) I have Promlems.

How to get Line properties of reporting services in c#

$
0
0

Hi,

I am trying to create a line programmatically using windows form. I am not able to get the properties of the below mentioned items in the image.

Line properties are pulled from RdlObjectmodel API.

enter image description here

How can I set the above mentioned properties in the below code.

CODE:

Line ln =newLine();
 ln.Name="f1";
 ln.Style.Color=System.Drawing.Color.Black;
 ln.Left=newReportSize(0.19,SizeTypes.Inch);
 ln.Top=newReportSize(0.91SizeTypes.Inch);
 ln.Width=newReportSize(1.02,SizeTypes.Inch);
 ln.Height=newReportSize(0.04,SizeTypes.Inch);

PrintDialog settings of NOT default printer are not preserved

$
0
0

PrintDialog settings of not default printer are not preserved. If you select a printer different from the proposed Windows Default Printer, the default settings are not taken into account. I've experienced this behaviour with SSRS ReportViewer .net component, but also other applications developed with the framework suffer of this issue.

steps to help us reproduce your issue

In the PrintDialog form choose a printer that differs from Windows Default Printer. Paper settings are not taken from printer default settings. While if you set that printer as default (avoiding to choose another printer in printer selection) the settings are preserved.

How get System Device's Location Information

$
0
0

When I go to Device manager, section "System Devices", Right click - "Properties", "Details", "Location Information", I get data like:

PCI Bus #, Device #, Function #.

I need it properly to PCI cards, I have tryed with many Root\CIMV2 tables, but still cannot get this data.

With next query I got info from devices, but not location information

ManagementObjectSearcher searcher =new ManagementObjectSearcher("root\\CIMV2","SELECT * FROM Win32_PnPEntity");

I'd really appreciate your help.

Thank you

IL Emit - set an existing property with a boolean value

$
0
0

Hi everyone,

I'm implementing an emitted propertychanged handler for my POCO object containing virtual properties, and I've got code that works to the point where propertychanged is being raised whenever I change the underlying property. The reason for doing this is that I am sharing a POCO object with the server (for better or for worse), where I will be sending modified objects to the server. I cannot decorate the object with attributes (since the server would also have these decorations) and I cannot use third-party tools such as Mono.Cecil, Fody or PostSharp due to policies. I need to track whether the object has been modified, and I'm stuck on this.

Here is the Emit that wraps my virtual properties with change notification:

MethodBuilder setMethodBuilder = typeBuilder.DefineMethod(setMethod.Name, setMethod.Attributes, setMethod.ReturnType, types.ToArray());
            typeBuilder.DefineMethodOverride(setMethodBuilder, setMethod);
            ILGenerator wrapper = setMethodBuilder.GetILGenerator();

            ...<Emit if (propertyvalue <> value) IsModified=true;>...

            wrapper.Emit(OpCodes.Ldarg_0);
            wrapper.Emit(OpCodes.Ldarg_1);
            wrapper.EmitCall(OpCodes.Call, setMethod, null);

What I need to do is get the set method of the existing "IsModified" boolean property and set it.

Here's an example of what I'd like to emit:

          

    public partial class AnEntity
    {
   string _myData;
public string MyData
        {
            get
            {
                return _myData;
            }
            set
            {

if(_myData <> value) IsModified = true;

                _myData = value;

                OnPropertyChanged("MyData");
            }
        }
        bool _isModified;
       public bool IsModified { get; set; }
        {
            get
            {
                return _isModified;
            }
            set
            {
                _isModified = value;
                OnPropertyChanged("IsModified");
            }
        }

I've been stuck on this for a while...I have managed to create a new property called "NewIsModified" in the new proxy class that was created, however, I'd very much like to reuse the existing IsModified property in my original POCO.

Any help would be greatly appreciated.

Kind regards.





A Debugger Bug(?)

$
0
0

Hello,

we have encountered a bug (most probably) in debugger of C#(.NET) VS 2015. The situation is following:

            // something ....

            for (int month = 1; month <= this.MainTariffInsurancePeriod * 12; month++)
            {
                ProgressionRow progressionRow = getProgressionRow(month);

 

               // something .....

               if (progressionRow.ColB_Month == 1)
                {
                    progressionRow.ColBK_BBASE = this.YearlyPremium * (LOWERED_ALLOCATION_YEAR1 + LOWERED_ALLOCATION_YEAR2);
                }

                 // continuation ....

The debugger (not runtime) bug has two demonstrations here:

1. 'month' variable is in debugger presented as value 361 thought in fact is  1 as should be.

2. progressionRow.ColB_Month property value is presented as 3770 though is 1 (program steps in into the if body)

The reason is probably related to the fact that before this code, but within in the same method there is another for loop using 'month' variable and another progressionRow declaration. The debugger shows the values from above definition.

Is there anybody who would care and fix a thing like that?

Thanks





WinForms controls memory issue?

$
0
0

I am experiencing a strange "memory leak" when I am using a pushbutton to start my program.  Here is a snippet:

using Kitware.VTK

namespace vtkclasspractice
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button_test_Click(object sender, EventArgs e)
        {

               "Body of my code"

        }

     }

}

My problem is that the memory in "Body of my code" never clears until I get out of the scope of button_test_Click.  There is a loop in "Body of my code" that is supposed to re-process ~5MB of image data, but instead it seems as though the memory just adds-up each iteration. 

I know this is a problem of the pushbutton, because when I place "Body of my code" right after InitializeComponent(), within the same scope, memory does not grow.  It seems as though garbage collection does not work inside of the button_test_Click method.

Any suggestions?

Viewing all 31927 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>