• 0

C# DLL


Question

6 answers to this question

Recommended Posts

  • 0
After someone creates a DLL in C# using the Microsoft Visual development environment, how would another programmer take that code, make a new project that includes the DLL's source and make a GUI that uses the DLL'S API?

normally we just add a reference to the dll so we can start using the codes from it.. u can do that from solution explorer right click the project > add reference

Link to comment
https://www.neowin.net/forum/topic/704468-c-dll/#findComment-590208254
Share on other sites

  • 0
normally we just add a reference to the dll so we can start using the codes from it.. u can do that from solution explorer right click the project > add reference

I have done a few things. I have created a console app to use as the front-end to the project. Then I have added the DLL as a reference like this:

1) In the Solution Explorer right-click "References" and select "Add Reference ...".

2) Select the "Browse" tab.

3) Navigate to the DLL and select it.

4) Add the appropriate using directive to the code file(s) where you want to use the DLL.

I have also found that I can add the Project that the DLL was made in into my new Solution file.

I have included the namespace of the DLL in the "using" section of my code.

And the intelligent type I am using recognizes this class when I declare it in my code.

But it does not seem to recognize all the methods (api's) of the class.

What am I doing wrong?

first_problem.jpg

Strangely, "Equals", "GetHashCode", "GetType" and "ToString" are not seen in the DLL's source code for available methods for this class.

Also, I know that if you double click on the added reference, an Object Explorer should come up showing the available methods. This is not what happens:

objects.jpg

So now to look closer at the DLL source code.Could there be a problem in the fact that the constructor ( private NookieBookieDoopieDoo() ) is

defined as a privvate? Could there be a problem that the methods are static?

It looks something like this:

namespace BladaFlabaDab
{

	public class NookieBookieDoopieDoo
	{

		private static readonly string SomethingYouDoNotNeedToKnow = @"SLAMADAMNADDORK";

		private NookieBookieDoopieDoo()
		{
		}



		public static void Send(string to, string subject, string body)
		{
			.
			.
			.
		}

		public static void Send(string to, string replyTo, string subject, string body)
		{
			.
			.
			.
		}

		private static void InitializeClient()
		{
			.
			.
			.
		}
	}
}

Could there be a problem in the fact that the constructor ( private NookieBookieDoopieDoo() ) is

defined as a privvate? Could there be a problem that the methods are static?

Link to comment
https://www.neowin.net/forum/topic/704468-c-dll/#findComment-590211424
Share on other sites

  • 0

The static keyword is used to mark a method/property/type as usuable without instantiation. So basically, I can make operations of a type available without having to declare and create a type:

public class MyTestClass
{
	public static void MyStaticOperation()
	{

	}

	public void MyInstanceOperation()
	{

	}
}

MyTestClass.MyStaticOperation(); // <- works, calling the operation without declaring an instance of MyTestClass.
MyTestClass.MyInstanceOperation(); // <- won't work, because we need to call MyInstanceOperation from an instance of MyTestClass.
MyTestClass instance = new MyTestClass();
instance.MyInstanceOperation(); // <- works, calling the operation from the instance.

The class you are using as a private constructor, so its likely that it will always be used in a static fashion, so really the entire class should be labelled as static.

Strangely, "Equals", "GetHashCode", "GetType" and "ToString" are not seen in the DLL's source code for available methods for this class.

All objects within the .NET Framework inherit from System.Object. This is an implicit inheritance because you have not expressed an explicit inheritance, e.g.:

public class MyTestClass : MyBaseClass
{
	// This class is explicitly inheriting from MyBaseClass
}

public class MyTestClass
{
	// This class is implicitly inheriting from System.Object
}

Those operations you see "Equals", "GetHashCode", "GetType" and "ToString" are implemented by the System.Object type, and become available to any subclass (which would be every object in the .NET Framework).

Hope that clears some stuff up for you.

Link to comment
https://www.neowin.net/forum/topic/704468-c-dll/#findComment-590212716
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Qualcomm's new Snapdragon Reality Elite chip brings on-device AI to Android XR devices by Pradeep Viswanathan Qualcomm has been delivering dedicated SoCs for mixed reality and spatial computing devices for several years. The journey started with the Snapdragon XR1, followed by the Snapdragon XR2 in 2019, the Snapdragon XR2 Gen 2 in September 2023, and finally the Snapdragon XR2+ Gen 2 in 2024. Today, Qualcomm announced a major upgrade with the new Snapdragon Reality Elite Platform, which targets premium mixed reality and spatial computing devices. OEMs can use this SoC to power both all-in-one video-see-through headsets and lightweight, tethered optical-see-through glasses. Qualcomm highlighted that the Snapdragon Reality Elite will power the next wave of Android XR devices coming later this year. These wearables will offer better visuals, improved power efficiency, and deeper on-device AI integration compared to the previous generation. The Snapdragon Reality Elite can deliver up to 48 TOPS of AI performance, allowing large language models and large vision models to run directly on the device for the first time. In addition to enabling new spatial AI experiences, these new AI capabilities will improve head and hand tracking, as well as see-through features. On the performance side, the Snapdragon Reality Elite offers up to 60% higher GPU performance, up to 30% higher CPU performance, and up to 160% higher NPU performance compared to the previous generation. The platform supports visuals of up to 4.4K per eye at 90 frames per second for sharper images and smoother motion. Qualcomm is also claiming significant efficiency improvements. The Snapdragon Reality Elite can offer up to 20% longer battery life under the same workload. More importantly, the chipset can run up to 12 degrees Celsius cooler under load, making headsets more comfortable for users to wear for longer periods. The platform also includes improvements to video see-through, featuring lower latency and better image quality. Qualcomm states that its EVA hardware block helps accelerate demanding computer vision workloads, improving how digital content blends with the real world.
    • Umm... GitHub continues to use AWS. That's the story, that's the headline. There's no "new" news here. GitHub continues to require additional capacity beyond the originally-planned Azure allocations. There's nothing special about this; nothing noteworthy. They're still using AWS' infra until the cutover is complete.
    • Hello, Also known for https://www.theguardian.com/technology/2009/jan/29/adware-internet.   Regards, Aryeh Goretsky    
    • Hello, I have used a few TEAM Group SSDs, USB flash drives, and Micro SDXC cards in the past. They all seemed to work fine. Regards, Aryeh Goretsky
    • "just $100 per TB"? Just? Are we trying to make this seem like the new normal? Kinda weird to make it sound like that is not a ridiculously expensive asking price.
  • Recent Achievements

    • Collaborator
      vjlex earned a badge
      Collaborator
    • Reacting Well
      Dys Topia earned a badge
      Reacting Well
    • Conversation Starter
      NovaEdgeX earned a badge
      Conversation Starter
    • One Year In
      Console General earned a badge
      One Year In
    • Week One Done
      Twozo Technologies earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      517
    2. 2
      +Edouard
      182
    3. 3
      PsYcHoKiLLa
      106
    4. 4
      Steven P.
      88
    5. 5
      ATLien_0
      68
  • Tell a friend

    Love Neowin? Tell a friend!