.NET Programming

133K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hello Experts,

I'm using asp.net 4.0 charts(ChartType: Bubble). I have X-axis shows States (values like AL, FL, NY,...) and Y-Axis is a Date(01/01/2018,02/01/2018,..) The date range on the Y-axis is from 01/01/2018 to 12/31/2018. One of the X-axis has two Y-Values. For instance NY has 01/01/2010,03/01/2018, I cannot show two DataPoints for 1 X-Axis item. I  tried this and still not working
series.CustomProperties = "IsXAxisQuantitative=True";
 DataPoint dp = new DataPoint();

dp = new DataPoint(i, val);
dp.SetValueY("01/01/2018");
dp.XValue = chart.Series["DateSeries"].Points.Count() * 2;
 dp.ToolTip = "First Date - 01/01/2018";
 chart.Series["DateSeries"].Points.Add(dp); 

dp.SetValueY("03/01/2018");
dp.XValue = chart.Series["DateSeries"].Points.Count() * 2;
 dp.ToolTip = "Second Date - 03/01/2018";
 chart.Series["DateSeries"].Points.Add(dp); 

Open in new window


The above code show only the tooltip twice ( the last one it got set i.e. Second Date - 03/01/2018), but not the two datapoints on Y axis. What I'm missing, please help.

Thanks,
ASPDEV
1
Become a CompTIA Certified Healthcare IT Tech
LVL 12
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Trying to create a Dynamics 365 package in Visual Studio.  Error when select to create.  Add the project types from the Dynamics 365 SDK.  All seemed to go ok.  Can't get passed the error on create.  Any help appreciated.  Larry
2
Looking at a piece of code and seeking to alter it as below. Any help appreciated.

      private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            var doc = webBrowser1.Document;
            var results = doc.GetElementsByTagName("OL")[0];
          foreach (HtmlElement result in results.Children)
            {
                if (result.TagName != "LI")

                {
                    continue;
                }
 
                var publishedInfo = new PublishedInfo();

                publishedInfo.Title =
                    result.GetElementsByTagName("H2")[0].InnerText;
             
          var Link =
                result.GetElementsByTagName("H2")[0].GetElementsByTagName("A")[0].GetAttribute("href");

I now want to navigate to this link and extract information from this link page. How do I do this?

Do i need to set up a new browser page? Any example of how to do this so i am in a position to extract new html elements from the link page will be great. Thanks.
1
threading.timer does not always start.
i start one threading.timer   that should check after 80 miliseconds if a write to serial port is stuck.  if it is stuck, it purges the comm port and tries to write again.
the problem is that sometimes it works,  and some times the thread does not start.  does anyone know about this behavior ?  and can this be fixed ?
it is running on a win ce  with visual studio  2005.
the write takes 3 miliseconds,  but when it get stuck,  it can take from 10 seconds to 20 seconds,  so checking after 80 miliseconds  seems good.
the code:

               If g.timerStarted = False Then            'starting the timer only one time
                    tTimer = New Threading.Timer(AddressOf tTimerTick, Nothing, CInt(80), CInt(80))
                    g.timerStarted = True
                Else
                    tTimer.Change(CInt(80), CInt(80))
                End If
             
                    doWriteToComm(InSendStr, InDevType, CommResult, RealWriteBytes)      
           
           
                tTimerClose()   '  here i change the timer to  tTimer.Change(Timeout.Infinite, Timeout.Infinite)

thanks.
1
I have a winforms ERP software built using C# dotnet. Database is sql server. My issue is with installation at client side. It is taking huge time to install. Major time consuming is the installation of MSSQL server and its Management Studio. Is it necessary that I should install sql server at client side? Is there any option where I can copy the mdf and ldf files of the sql database to the system and connect with my application (like we do with access database)
1
How to resolve culture problem of decimal and thousand separator  of number of excel using c#
1
Hello,

I am trying to call a WCF Service from Jquery.
When i run the application as of now, it goes into error.
All i get is :         XHR: [object Object]

Earlier i was getting CORS issues.
I Included "            "Access-Control-Allow-Origin" under Application_Beginrequest of global.asax file.


Just to make sure the service is working good, I tried calling the service from a server side button control click and it works good and returns the data.
However, when i call it form Jquery, it goes into error and does nothing.

Can you point out what is wrong with this code?  Why is it failing.



Service

namespace EnrSvcOut
{
    // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
    [ServiceContract]
    public interface IServiceEnrollmentOutcome
    {
        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetServicePrograms")]
        List<SvcEnrOutProgram> GetServicePrograms();
    }
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }

Open in new window

1
Need help to uninstall .net 4.7.2 on my Windows 2016 Server.

I installed .net 4.7.2 for my Exchange 2016 CU9 running on Windows 2016 Data Center.

After getting a million errors on my Exchange Servers I was asked to remove .net 4.7.2 and revert back to .net 4.7.1

I found no way on the Server to remove .net except for 4.6 3.5 and 2.0   4.7 does not show.

I did find this but not sure which is correct.
Open an admin command prompt and paste this script:
%windir%\microsoft.net\Framework64\v4.0.30319\SetupCache\v4.7.02558\setup.exe /uninstall /x86 /x64 /passive /norestart
If you have 4.7.1 as the latest version, this will run the removal tool. Reboot, and it will be removed.


What would the proper method of removing .net 4.7.2 be?

Can I use the above command? What changes would I need to make it work?

Thank  you,
1
Hello Experts,
I have a Forget Password link in the Login Page.  When clicked, I received an email with a link to Reset the password.  In email, it contains a link, which will take you to the page where you can reset it. The problem is when I click on the link, the page error ed out with the following error message.  Any idea what is going on.  Any idea how to debug the page when loaded directly from the link?  Please let me know if you can.  Thank you in advance.

Thank You!

Server Error in '/' Application.

Object reference not set to an instance of an object.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:
1
Hello Experts,

This issue is concerning an ASP.NET webpage that's currently used in our contact center.
It's a personalized launch page for users, with links they need to do their jobs.
But recently some of the tools used by our colleagues have changed.

The problem is, some links now work faster in IE and some faster in chrome.
And the difference in speed is rather dramatic in some cases.

I need a way to force the individual links to open in the fastest browser.

Many Thanks!
Maurice
1
C++ 11 Fundamentals
LVL 12
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

How do you rename the namespace of a compiled DLL?
1
I am trying to query/get the value of a node from an xml which has namesopaces.
However I always get "Object reference not set to an instance of an object."

Here is the xml that I am using -



I am using the following code to retreive the value of the node, as marked in the xml -

 string xmlResponse = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed xml:base=\"https://abcd.com/_api/\" xmlns=\"http://www.w3.org/2005/Atom\" xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\"><id>asd-123-qwe-456-zxc</id><title /><updated>2018-09-18T12:18:54Z</updated><entry><id>https://abcd.com/_api/SP.WebParts.WebPartDefinitionasd-123-qwe-456-zxc</id><category term=\"SP.WebParts.WebPartDefinition\" scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\" /><link rel=\"edit\" href=\"SP.WebParts.WebPartDefinitionasd-123-qwe-456-zxc\" /><link rel=\"http://schemas.microsoft.com/ado/2007/08/dataservices/related/WebPart\" type=\"application/atom+xml;type=entry\" title=\"WebPart\" href=\"SP.WebParts.WebPartDefinitionasd-123-qwe-456-zxc/WebPart\"><m:inline><entry><id>https://abcd.com/_api/SP.WebParts.WebPartDefinitionasd-123-qwe-456-zxc/WebPart</id><category term=\"SP.WebParts.WebPart\" scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\" /><link 

Open in new window

1
Hi,
I am using Renci.SshNet to upload the files over SFTP. Below is my code.

var connectionInfo = new ConnectionInfo(host,
                                    objFI.UserId,
                                    new PasswordAuthenticationMethod(objFI.UserId, objFI.Password),
                                    new PrivateKeyAuthenticationMethod("rsa.key"));
 try
                    {
                        using (SftpClient sftp = new SftpClient(connectionInfo))
                        {
                            try
                            { 
                                    sftp.Connect();
                                    if (sftp.IsConnected)
                                    {
                                        using (var file = File.OpenRead(FilewithUploadingext))
                                        {
                                            if (file != null)
                                            {
                                                sftp.BufferSize = 4 * 1024; // bypass Payload error large files                                                     
                                                sftp.UploadFile(file, Path.GetFileName(FilewithUploadingext), (uploadCallback) =>
                                                {
                                                    ServerFileSize = uploadCallback;
                                                });
                                            }
              

Open in new window

1
Hello Experts,
I have a Onclick event attached to button which should open a window (on Javascript), which is working just fine.  But, when I click on another URL same window opens up, which is not related to the URL at all.  Any idea what could be going on?  Please try to help.  Thank you in advance.

Note:  Due to company's restrictions I will not be able to post the code here.

Thank you!
0
Hello,

I'm trying to load multiple results into a reportviewer.  I'm having the user select multiple rows in a datagridview then click a button to load those into a reportviewer form.  It works fine for a single event and associated sub table data.  I envision having the reports sequentially page after page but I'd also be fine if it opened up multiple reportviewer forms ready for printing or saving.  I'd have to limit the total number of openable events I suppose, otherwise a user could open hundreds and that would bog down or fail but that should be easy.  

I played around with a query to capture all the events by serialno using an IN statement in the query builder for the dataset, but I kept getting an error and the reportviewer may not be able to handle it anyways so I thought I would ask before spending too much time on that.

Here's my attempted code that opens only the last selected event in the reportviewer:

       Dim selectedRowCount As Integer = Form1.dgResults.Rows.GetRowCount(DataGridViewElementStates.Selected)
        Dim SerialNo As Integer = Nothing

        For i = 0 To selectedRowCount - 1
            SerialNo = Form1.dgResults.SelectedRows(i).Cells("SerialNo").Value
            Debug.Print(RecordSerialNo)
            Try
             
               
                Me.IAdapter.Fill(Me.DataSet1.I, SerialNo)
                Me.pAdapter.Fill(Me.DataSet1.p, SerialNo)
                Me.vAdapter.Fill(Me.DataSet1.v, SerialNo)
                

Open in new window

0
Constructors are not inherited:
The sub class cannot inherit constructors from its super class. Consider the following example:
1
2
3
4
5
6
7
8
9
10
11
public class Super {
    protected String text;
 
    public Super(String text) {
        this.text = text;
    }
}
 
public class Sub extends Super {
 
}
We can create a new instance of Super like this:
1
Super super = new Super(“Hello”);   //OK
But we cannot do the same for the Sub class:
1
Sub sub = new Sub(“Hello”); //Compile error, since constructor is not inherited
The solution is to write a constructor for the sub class and call the super’s constructor, for example:
1
2
3
4
5
6
public class Sub extends Super {
 
    public Sub(String text) {
        super(text);
    }
}

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java

i wrote as below

package SuperSub;
public class Super {
    protected String text;
 
    public Super(String text) {
        this.text = text;
    }
}
 

Open in new window


package SuperSub;
public class Sub extends Super {
	//Super super = new Super(“Hello”);
}

Open in new window


i am getting error in line 2 of Sub class
Implicit super constructor Super() is undefined for default constructor. Must define an explicit constructor
package SuperSub;
public class Sub extends Super {

	public Sub(String text) {
		super(text);
		// TODO Auto-generated constructor stub
	}
	//Super super = new Super(“Hello”);
}

Open in new window

above is fine though not sure why i cannot just have Sub empty class?
Please advise
0
package SuperThis;
public class Sub extends Super {
	/*public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}*/
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
       super.bar();
       this.bar();
    }
  
    	// Sub sub=new Sub();
    	 //   sub.test();
    
        this.test();
}

Open in new window

why above code is not working
i see error as below at line 21,15
Syntax error, insert "}" to complete ClassBody

Please advise
0
The super keyword:
In Java, the superkeyword is used to access members of the super type from the sub type. For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Super {
    protected void bar() {
        System.out.println("Super.bar()...");
    }
 
}
 
public class Sub extends Super {
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
        super.bar();
        this.bar();
    }
}
Here, we can see that both classes have a method called bar() (overriding). Therefore, if we want to invoke the super’s version of the bar() method, the super keyword is used.
 

Open in new window


super with this example not working for me
package SuperThis;
public class Sub extends Super {
	public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    //public void test() {
       // super.bar();
        //this.bar();
   // }
        
}

Open in new window


above code giving below error
Cannot use super in a static context
Cannot use this in a static context

how to fix this
package SuperThis;

public class Test {
public static void main(String[] args) {
	 Sub sub=new Sub();
	    sub.test();
}
}

Open in new window


Super.bar()...
Sub.bar()...


does it need separate class for this to test
package SuperThis;
public class Sub extends Super {
	/*public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}*/
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
       super.bar();
       this.bar();
    }
  
    	// Sub sub=new Sub();
    	 //   sub.test();
    
        test();
}

Open in new window

how to test in same Sub class

above gives error at line 20
Multiple markers at this line
      - This method requires a body instead of a
       semicolon
      - Return type for the method is missing
      - Duplicate method test() in type Sub

please advise
0
Remember that Java does not allow a class inherits two or more classes directly. To understand why multiple inheritance is not allowed, consider the following example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}
 
 
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}
Suppose that we want to write a class C that extends both A and B like this:
1
2
3
4
5
public class C extends A, B {
    public void methodC() {
        foo();
    }
}
As you can see, both A and B has a method called foo(), so which foo() method the class C invokes exactly? from A or B? This case is ambiguous hence Java does not allow.

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java

i tried as below

package MultipleInheritance;
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}


package MultipleInheritance;
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}


package MultipleInheritance;
public class C extends A, B {
    public void methodC() {
        foo();
    }
}

Open in new window


on C class i get below error

Multiple markers at this line
      - Syntax error on token "extends", delete this token
      - Syntax error, insert "ClassBody" to complete
       ClassDeclaration
      - Syntax error, insert "}" to complete Block

can you please advise what above error means

it did not say "multiple inheritance of state not allowed"

Please advise
0
CompTIA Network+
LVL 12
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

6. Multiple inheritance of state is not allowed:
Remember that Java does not allow a class inherits two or more classes directly. To understand why multiple inheritance is not allowed, consider the following example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}
 
 
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}
Suppose that we want to write a class C that extends both A and B like this:
1
2
3
4
5
public class C extends A, B {
    public void methodC() {
        foo();
    }
}
As you can see, both A and B has a method called foo(), so which foo() method the class C invokes exactly? from A or B? This case is ambiguous hence Java does not allow.
 
7. Multiple inheritance of type is allowed:
This means Java does allow multiple inheritance between interfaces. For example:
1
2
3
4
5
6
7
8
9
10
11
public interface X {
    public void methodX();
}
 
public interface Y {
    public void methodY();
}
 
public interface Z extends X, Y {
    public void methodZ();
}
This is allowed because interfaces do not have concrete methods, thus there is no ambiguity.
Likewise, we can have a class implements multiple interfaces:
1
2
3
4
5
6
7
public class Sub implements X, Y, Z {
    public void methodX() { }
 
    public void methodY() { }
 
    public void methodZ() { }
}

Open in new window


if both Interface X and Interface Y has same method called methodAB what happens?



Open in new window

0
Hello Experts,
In a web page, when I click on a link, it fails.  Upon doing further research I found that I pass Line 1, but it changes to Line 2 automatically at the Run Time.  Any idea what is going on?  Please try to help.  Thank you very much in advance.

Line 1: http://abc.com/DataSources/APP DB/IDocument?AutoLogoutOnClose=True&AppName=TKT_DET&TktId=333333
Line 2: http://abc.com/DataSources/APP%20DB/IDocument?AutoLogoutOnClose=True&amp;AppName=TKT_DET&TktId=333333

Thank you!
0
Let’s look at the constructor of the Truckclass - it can access the protected field numberOfWheels and the default field name. However, it cannot access the private field age. We can write:
1
2
3
Truck truck = new Truck();
truck.start();
truck.move();
But the Java compiler will complain if we try to invoke the private method test():
1
truck.test();   // COMPILE ERROR, since private member is not inherited

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java


i supposed to put below code in which class Car or Truck or Moveable?


public class Truck extends Car {
    public Truck() {
        numberOfWheels = 8;
        name = "Truck";
        age=10;
    }
    
    Truck truck = new Truck();
    truck.start();
    truck.move();
    
}

Open in new window




or as below

public class Car extends Vehicle {
	String name;
	protected int age;
    //protected int age;
    protected int numberOfWheels = 4;
    
    public void move() {
        System.out.print("Moving by engine...");
    }

	@Override
	public void start() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void stop() {
		// TODO Auto-generated method stub
		
	}
	
	/*Truck truck = new Truck();
	truck.start();
	truck.move();*/
}

Open in new window


below i cannot put as it is interface

public interface Moveable {
    public void start();
 
    public void stop();
 
    public void move();
}

Open in new window


please advise
0
Don’t use a for loop with an index (or counter) variable if you can replace it with the enhanced for loop (since Java 5) or forEach (since Java 8). It’s because the index variable is error-prone, as we may alter it incidentally in the loop’s body, or we may starts the index from 1 instead of 0.
Consider the following example that iterates over an array of Strings:
1
2
3
4
5
String[] names = {"Alice", "Bob", "Carol", "David", "Eric", "Frank"};
 
for (int i = 0; i < names.length; i++) {
    doSomething(names[i]);
}
As you can see, the index variable i in this for loop can be altered incidentally which may cause unexpected result. We can avoid potential problems by using an enhanced for loop like this:
1
2
3
for (String aName : names) {
    doSomething(aName);
}
This does not only remove potential issues but also make the code cleaner and more succinct. 

Open in new window


how is it possible to do for loop index modifycation?

how enhanced for loop is diferent from for each loop?

is there any case where we still has to use traditional for loop with index
please advise
0
public class CollectionsRef {
 
    private HashSet<Integer> numbers;
 
    public ArrayList<String> getList() {
 
        return new ArrayList<String>();
    }
 
    public void setNumbers(HashSet<Integer> numbers) {
        this.numbers = numbers;
    }
}
Look at the reference types which are collection implementation classes - this locks the code to work with only these classes HashSet and ArrayList. What if we want the method getList() can return a LinkedList and the method setNumbers() can accept a TreeSet?
The above class can be improved by replace the class references to interface references like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class CollectionsRef {
 
    private Set<Integer> numbers;
 
    public List<String> getList() {
        // can return any kind of List
     [b]   return new ArrayList<String>();[/b]
    }
 
    public void setNumbers(Set<Integer> numbers) {
        // can accept any kind of Set
        this.numbers = numbers;
    }
}

Open in new window


can we have generic List as return type to provide more flexibility to future changes to collection implementation?
https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know
Please advise
0
Avoid Redundant Initialization (0-false-null)
It’s very unnecessary to initialize member variables to the following values: 0, false and null. Because these values are the default initialization values of member variables in Java. For example, the following initialization in declaration is unnecessary:
1
2
3
4
5
public class Person {
    private String name = null;
    private int age = 0;
    private boolean isGenius = false;
}
This is also redundant:
1
2
3
4
5
6
7
8
9
10
11
public class Person {
    private String name;
    private int age;
    private boolean;
 
    public Person() {
        String name = null;
        int age = 0;
        boolean isGenius = false;
    }
}
Therefore, if you know the default initialization values of member variables, you will avoid unnecessary explicit initialization. See more here:

Open in new window


i am not clear on below

This is also redundant:


does it mean initialization in the constructor as well apart from at class level

public Person() {
        String name = null;
        int age = 0;
        boolean isGenius = false;
    }
}

https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know
Please advise
0

.NET Programming

133K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.