|
I resent the use of the term spamming and the confrontational tone of your posting.
For your information I had an account with another name (company email, no longer accessible), posted in the WPF forum, got no answer after many days, posted a link in this forum, and got an answer almost immediately. Hence why I am/was not sure which was the best forum for the question.
|
|
|
|
|
|
Thank you for the constructive suggestion.
|
|
|
|
|
I have C# COM dll used in one of the module (lets call as A) and it already into the market.
For my other new module , i need same functionality as C# COM dll, So i used the same code and generated dll(the Common C# DLL is same for two modules and need to located in same place after installation)
Since C# COM dll name and location is same for both modules, i cant work on both the modules at a time
either i need to play with register /unregister and work with one module.
How can i make this C# COM dll with same name and same location to work for two projects/modules?
Help is greatly appreciated.
|
|
|
|
|
Member 11732139 wrote: i need same functionality as C# COM dll, So why are you creating a different dll?
|
|
|
|
|
the two modules are different and install packages of modules are different
when two modules insatlled in machine then common dll contradicts!!
|
|
|
|
|
Sorry, but I do not understand what you mean. If you have a common dll then you only need it installed once.
|
|
|
|
|
This is possibly a misunderstanding because the word you are using mean something else in this context: perhaps you should try explaining again in more detail exactly what is giving you a problem?
Examples help as well!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
cant send file bigger that 1 megabit ( Server_client )
private byte[] GetFileInfo(string fname, string fext, long fsize)
{
byte[] data = new byte[1024];
byte[] type = Encoding.UTF8.GetBytes("fff");
byte[] ext = Encoding.UTF8.GetBytes(fext);
byte[] extE = Encoding.UTF8.GetBytes(":");
byte[] sizeS = Encoding.UTF8.GetBytes(fsize.ToString());
byte[] sizeE = Encoding.UTF8.GetBytes("s");
byte[] name = Encoding.UTF8.GetBytes(fname);
byte[] nameE = Encoding.UTF8.GetBytes("?");
Array.Copy(type, data, type.Length);
Array.Copy(ext, 0, data, type.Length, ext.Length);
Array.Copy(extE, 0, data, ext.Length + type.Length, extE.Length);
Array.Copy(sizeS, 0, data, ext.Length + type.Length + extE.Length, sizeS.Length);
Array.Copy(sizeE, 0, data, ext.Length + type.Length + extE.Length + sizeS.Length, sizeE.Length);
Array.Copy(name, 0, data, ext.Length + type.Length + extE.Length + sizeS.Length + sizeE.Length, name.Length);
Array.Copy(nameE, 0, data, ext.Length + type.Length + extE.Length + sizeS.Length + sizeE.Length + name.Length, nameE.Length);
byte[] newdata = new byte[ext.Length + extE.Length + sizeS.Length + sizeE.Length + name.Length + nameE.Length + type.Length];
Array.Copy(data, newdata, newdata.Length);
return newdata;
}
private byte[] GetBinaryFile(string filename)
{
byte[] bytes;
using (FileStream file = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
bytes = new byte[file.Length];
file.Read(bytes, 0, (int)file.Length);
}
return bytes;
}
}
}
modified 7-Jun-18 1:26am.
|
|
|
|
|
Please delete your duplicate of this question. Also, edit this and remove all the code not relating to the problem, and add some details about exactly what happens.
|
|
|
|
|
Is this for a DOS attack?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Is that MS-DOS or PC-DOS?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
|
You programmed all that, and can't figure out what determines the length of the buffer?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
When the 102400000 byte buffer (10megabit buffer length) ,software receives an error
|
|
|
|
|
Hussein Tb wrote: the 102400000 byte buffer (10megabit buffer length)
When I last did arithmetic, that number is over 100 million, not ten. And it's bytes, not bits.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
hi gang i have a litle problem c# ...
i have 4 textbox i need to calculate first (tb2 x tb3 x 60) after tb1 / (the result) and after x 100
and show the result in texbox4
textbox4 = textbox1 / (textbox2 x textbox3 x 60) x 100
|
|
|
|
|
First, use int.TryParse (or double.TryParse if appropriate) to convert each value to an numeric:
double t1;
if (!double.TryParse(textBox1.Text, out t1))
{
... Report problem to user - he typed a bad number ...
return;
} When you have the four values, it's trivial:
TextBox4.Text = (t1 / (t2 * t3 * 60 ) * 100).ToString();
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
What happened to "We do not do your homework?"
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
It's a fine line between "doing the homework" and "giving enough so they can finish it", isn't it?
I didn't think just pointing him at the TryParse documentation would be enough, he is a beginner after all - and thoroughly lost by the look of it!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
On second thought, I think you're right. Your mentality is not "throw 'em to the wolves", but do what you can to help.
There is a difference between asking for a clue and asking for it to be done for you. Your post embodies the teaching spirit.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thank you.
I think that's the nicest thing anyone has said to me all week.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I am writing a C# application with Visual Studio Express 2005 and I need to query the available com ports and their friendly names. The first part is easy, I can simply call SerialPort.GetPortNames(). In order to get the friendly names, I found the following code on the internet:
for (int i = 0; i < availableComPorts.Length; i++)
{
try
{
string temp = "(" + availableComPorts[i] + ")";
foreach (ManagementObject queryObj in searcher.Get())
{
if ((queryObj["Name"] != null) && (queryObj["Name"].ToString().EndsWith(temp)))
{
ComPortInfo comPortsInfo = new ComPortInfo();
comPortsInfo.officalName = availableComPorts[i];
comPortsInfo.userfriendlyDescription = queryObj["Caption"].ToString().Replace("(" + availableComPorts[i] + ")", "").Trim();
comPortsInfo.manufacturer = queryObj["Manufacturer"].ToString();
comPortInfoArrayList.Add(comPortsInfo);
}
}
}
catch (Exception)
{
}
}
The problem with the code above is that it takes about 1.5 seconds(!) to execute on my computer which is too slow. After further investigations I found the following post [winapi - How do I get a list of available serial ports in Win32? - Stack Overflow](https://stackoverflow.com/questions/1388871/how-do-i-get-a-list-of-available-serial-ports-in-win32) which refers to the following project: [CEnumerateSerial v1.34](http://www.naughter.com/enumser.html). This project seems very promising, especially the "Device Manager (SetupAPI - GUID_DEVINTERFACE_COMPORT)" method, which executes extremely quickly on my computer:
_Return_type_success_(return != 0) BOOL CEnumerateSerial::QueryRegistryPortName(_In_ ATL::CRegKey& deviceKey, _Out_ int& nPort)
{
BOOL bAdded = FALSE;
LPTSTR pszPortName = nullptr;
if (RegQueryValueString(deviceKey, _T("PortName"), pszPortName))
{
const size_t nLen = _tcslen(pszPortName);
if (nLen > 3)
{
if ((_tcsnicmp(pszPortName, _T("COM"), 3) == 0) && IsNumeric((pszPortName + 3), FALSE))
{
nPort = _ttoi(pszPortName + 3);
bAdded = TRUE;
}
}
LocalFree(pszPortName);
}
return bAdded;
}
_Return_type_success_(return != 0) BOOL CEnumerateSerial::QueryUsingSetupAPI(const GUID& guid, _In_ DWORD dwFlags, _Inout_ CPortsArray& ports, _Inout_ CNamesArray& friendlyNames)
{
#ifndef CENUMERATESERIAL_MFC_EXTENSIONS
ports.clear();
friendlyNames.clear();
#else
ports.RemoveAll();
friendlyNames.RemoveAll();
#endif //#ifndef CENUMERATESERIAL_MFC_EXTENSIONS
HDEVINFO hDevInfoSet = SetupDiGetClassDevs(&guid, nullptr, nullptr, dwFlags);
if (hDevInfoSet == INVALID_HANDLE_VALUE)
return FALSE;
BOOL bMoreItems = TRUE;
int nIndex = 0;
SP_DEVINFO_DATA devInfo = { 0 };
while (bMoreItems)
{
devInfo.cbSize = sizeof(SP_DEVINFO_DATA);
bMoreItems = SetupDiEnumDeviceInfo(hDevInfoSet, nIndex, &devInfo);
if (bMoreItems)
{
BOOL bAdded = FALSE;
ATL::CRegKey deviceKey;
deviceKey.Attach(SetupDiOpenDevRegKey(hDevInfoSet, &devInfo, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE));
if (deviceKey != INVALID_HANDLE_VALUE)
{
int nPort = 0;
if (QueryRegistryPortName(deviceKey, nPort))
{
#ifndef CENUMERATESERIAL_MFC_EXTENSIONS
ports.push_back(nPort);
#else
ports.Add(nPort);
#endif //#ifndef CENUMERATESERIAL_MFC_EXTENSIONS
bAdded = TRUE;
}
}
if (bAdded)
{
ATL::CHeapPtr<BYTE> byFriendlyName;
if (QueryDeviceDescription(hDevInfoSet, devInfo, byFriendlyName))
{
#ifndef CENUMERATESERIAL_MFC_EXTENSIONS
friendlyNames.push_back(reinterpret_cast<LPCTSTR>(byFriendlyName.m_pData));
#else
friendlyNames.Add(reinterpret_cast<LPCTSTR>(byFriendlyName.m_pData));
#endif //#ifndef CENUMERATESERIAL_MFC_EXTENSIONS
}
else
{
#ifndef CENUMERATESERIAL_MFC_EXTENSIONS
friendlyNames.push_back(_T(""));
#else
friendlyNames.Add(_T(""));
#endif //#ifndef CENUMERATESERIAL_MFC_EXTENSIONS
}
}
}
++nIndex;
}
Now, the problem is that I don't know how to convert this to C#. I was able to convert some of it into C# using P/Invoke, for example:
[DllImport("setupapi.dll", CharSet = CharSet.Auto)]
static extern IntPtr SetupDiGetClassDevs(
ref Guid ClassGuid,
[MarshalAs(UnmanagedType.LPTStr)] string Enumerator,
IntPtr hwndParent,
uint Flags);
[StructLayout(LayoutKind.Sequential)]
struct SP_DEVINFO_DATA
{
public UInt32 cbSize;
public Guid ClassGuid;
public UInt32 DevInst;
public IntPtr Reserved;
}
[DllImport("setupapi.dll", SetLastError = true)]
static extern bool SetupDiEnumDeviceInfo(IntPtr DeviceInfoSet,
uint MemberIndex,
ref SP_DEVINFO_DATA DeviceInfoData);
but I'm unable to figure out how to convert the calls to ATL. Can anybody please advice on how I can convert the code to C#?
|
|
|
|
|
You should first figure out why your first solution was "slow" before jumping to a "new" solution.
And "slow" is relative.
Perhaps you're not accounting for dll load time; or should be doing your "port query" at startup as a "parallel" task.
And what do you mean by "friendly names"?
The port names are "COMx"; what do you expect to see?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|