I am try to automate Gupta's Team Developer control as mention in
Centura Gupta Team Developer Automation Possibility
I download 32-bit trial version of Team Developer 7.1
[DllImport("user32.dll")]
static extern IntPtr WindowFromPoint(System.Drawing.Point p);
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern long GetClassName(IntPtr hwnd, StringBuilder lpClassName, long nMaxCount);
const string guptadllpath = #"C:\program files (x86)\gupta\team developer 7.1\VTI71.DLL";
[DllImport(guptadllpath)]
extern static int VisTblFindString(IntPtr hwndTable, int lStartRow, IntPtr hwndColumn, string lpctszSearchFor);
IntPtr _wndFromPoint;
private void MainForm_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Cursor.Current = Cursors.Default;
Point p = PointToScreen(e.Location);
_wndFromPoint = WindowFromPoint(p);
StringBuilder classText = new StringBuilder(256);
GetClassName(_wndFromPoint, classText, 256);
listBox1.Items.Add("Class: " + classText);
int a = VisTblFindString(_wndFromPoint, 0, IntPtr.Zero, "Pat");
this.Text = a.ToString();
}
}
But give me below error:
System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
My sample application is
Please suggest me how to resolve this error. Is it correct way to use Gupta's dll in c# for automate?
Thanks,
Calling VisTblFindString(..) from outside won't work. Even though the function takes a window handle as a parameter this will only work from inside the "grid-application". The reason is that one process cannot peek into the memory of another process (ok you can use GetWindowText(..) but this is not applicable here since in a grid not every cell is a distinct window).
You have to set up some interprocess-communication. Unfortunately in gupta grid there are no built-in functions that support this.
The only way I see is that you have to modify the grid-application (not sure if you control the source code of it). If you have the possibility to modify it then you can implement automation e.g. via Windows messages.
I dont know c# from a bar of soap - but if you are using the dll outside of TeamDeveloper, it could be the way you have imported it , or you haven't registered the dll, or you dont have a license to use it outside of TeamDeveloper , or you should be using the 64bit version. A Trial license may not cut it. But I'm just guessing here.
Related
First, I know there are a lot of posts about clickonce test certificates renewal on OF but this is not the core of the question.
I have an internal clickonce app signed with a Test Certificate that expired.
We now need to deploy a new version but we don't want to force everyone to reinstall our app and risk them to lose personnal settings.
I tried using OceanAirdrop's ExtendClickOnceCertificate (a derivative from the original MS RenewCert application) but I always end up with a SHA1 certificate while the original one is SHA256. How can I get it (or any other renewal tool) to really make an extended clone of the original?
(The basic renewal problem was already discussed here. This question is about the renewal of a SHA256 certificate)
I made some changes in the Crypt.cs File to solve this issue.
First add this two struct:
[StructLayout(LayoutKind.Sequential)]
public struct CRYPT_ALGORITHM_IDENTIFIER
{
[MarshalAs(UnmanagedType.LPStr)]
public string pszObjId;
public CRYPTOAPI_BLOB parameters;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CRYPTOAPI_BLOB
{
public uint cbData;
public IntPtr pbData;
}
Then, modify the CertCreateSelfSignCertificate function like this:
[DllImport("Crypt32.dll", SetLastError = true, ExactSpelling = true)]
internal static extern IntPtr CertCreateSelfSignCertificate(
IntPtr providerHandle,
ref CRYPT_DATA_BLOB subjectIssuerBlob,
int flags,
IntPtr pinfo,
ref CRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
Native.SYSTEMTIME pStartTime,
Native.SYSTEMTIME pEndTime,
IntPtr extensions);
In Program.cs, before calling CertCreateSelfSignCertificate, add this:
Crypt.CRYPT_ALGORITHM_IDENTIFIER signatureAlgorithm = new Crypt.CRYPT_ALGORITHM_IDENTIFIER {
pszObjId = "1.2.840.113549.1.1.11"
};
Finally, change the call to the CertCreateSelfSignCertificate to look like this:
hCertContext = Crypt.CertCreateSelfSignCertificate(hCPContext, ref certNameBlob, 0,Info,ref signatureAlgorithm, null, certExpireDate, IntPtr.Zero);
And that is all. Compile the solution and run the command. This worked for me.
I want to use C++ DLL in Unity, but I am prompted with “DllNotFoundException” error in Unity.I tried the method of others on the network, it didn't work for me.
I tried the method on Unity's official website, but it didn't work.
https://docs.unity3d.com/2017.3/Documentation/Manual/NativePlugins.html
https://docs.unity3d.com/2017.3/Documentation/Manual/PluginsForDesktop.html
Running the SimplestPluginExample Demo of Unity's official website is also prompted with “DllNotFoundException” error in Unity.
extern "C" int __declspec(dllexport) AddTwoIntegers(int a, int b)
{
return a + b;
}
put the MyDLL.dll in Assets/Plugins
[DllImport("MyDLL")]
private static extern int AddTwoIntegers(int a, int b);
void Start ()
{
Debug.Log(AddTwoIntegers(2, 3));
}
DllNotFoundException: MyDLL
Just try with extension. And put importing dll(MyDLL.dll) in output path of the function Caller project.
[DllImport("MyDLL.dll")]
private static extern int AddTwoIntegers(int a, int b);
void Start ()
{
Debug.Log(AddTwoIntegers(2, 3));
}
I solved my problem.My system is 64 bit.I used VS to create 64-bit DLLs.This dll in my Unity is correct,not error tip.
I want to use a standard dialog to solicit user input of an ADO.net connection string. It is trivial to do for the oledb connection string as described here:
MSDN Article on MSDASC.DataLinks().Prompt
I've also found examples that use Microsoft.Data.ConnectionUI.dll and MicrosoftData.ConnectionUI.Dialog.dll from VS (HOWTO: Using the Choose Data Source dialog of Visual Studio 2005 from your own code).
Unfortunately these DLLs are not licensed for redistribution.
Is there a standard dialog for choosing a data source that can be distributed with my application?
#rathkopf, it looks like these DLLs have been authorized for redistribution since Feb 2010:
http://connect.microsoft.com/VisualStudio/feedback/details/423104/redistributable-microsoft-data-connectionui-dll-and-microsoft-data-connectionui-dialog-dll
http://code.msdn.microsoft.com/Connection
The source code for these DLLs is now available: http://blogs.msdn.com/b/vsdata/archive/2010/02/02/data-connection-dialog-source-code-is-released-on-code-gallery.aspx
Also you can do this programmatically using the DataLink Properties:
Add the reference to ADODB.DLL (from .NET reference) and Microsoft OLE DB Service Component 1.0 Type Library from the COM tab in your visual studio reference tab.
using ADODB;
using Microsoft.Win32;
public partial class ConnectionStringStep : Form
{
private const string MSSQL_PROVIDER = "Provider=SQLOLEDB.1";
private const string ORACLE_PROVIDER = "Provider=MSDAORA.1";
private const string MSSQL = "MSSQL";
public ConnectionStringStep()
{
InitializeComponent();
}
private static string DataBaseType()
{
//get the data from some previous screen or some kind of storage
return MyStorage.GetProperty("DATABASE_TYPE") ?? "MSSQL";
}
private void button1_Click(object sender, EventArgs e)
{
var dataBaseType = DataBaseType();
var adodbConnection = new Connection
{
ConnectionString = dataBaseType == MSSQL ? MSSQL_PROVIDER : ORACLE_PROVIDER
};
object connection = (object) adodbConnection;
var dialog = new MSDASC.DataLinks();
dialog.PromptEdit(ref connection);
connectionTextBox.Text = adodbConnection.ConnectionString;
}
}
DataLink Properties Reference
There is now a NuGet package by Microsoft providing this dialog:
DataConnectionDialog.
Sample usage:
var dialog = new DataConnectionDialog();
dialog.DataSources.Add(DataSource.SqlDataSource);
dialog.ConnectionString = connectionString;
if (DataConnectionDialog.Show(dialog) == System.Windows.Forms.DialogResult.OK)
{
connectionString = dialog.ConnectionString;
}
It's related, but I'm now sure how you can embed this behavior inside your application.
Every time I need one, I create an empty text file, changed its file extension to ".udl" and double-click it; when I'm done, I close that application, rename that file back to ".txt" and open with Notepad.
It appears that such a beast does not exist. I've written my own dialog and can include it in projects as needed.
Update:
The source code for these DLLs are now available as per #code4life's answer.
I need a Win client for Amazon S3 that utilizes SOAP protocol for all transactions. As far as I see most solutions are REST based rather than SOAP. Any ideas?
EDIT:
Just want to clarify: please do not suggest using REST instead. I am perfectly aware of what can or cannot be done with either protocol. So if I ask for this specific solution, there is a reason for that.
What I need is a working software for Win platform that utilizes SOAP for Amazon S3, not suggestions how to do my job. Thank you.
Start Visual Studio 2008, create a new C# Windows console application.
Add the S3 WSDL as a service reference. In Solution Explorer, right click References, select Add Service Reference. Type in the S3 WSDL address in the Address box: http://s3.amazonaws.com/doc/2006-03-01/AmazonS3.wsdl. Click Go. "AmazonS3" should show in the Services box. Enter a namespace. I entered Amazon.S3. Click OK.
Modify Program.cs to look something like the following:
using System;
using System.Globalization;
using System.Text;
using System.Security.Cryptography;
using ConsoleApplication1.Amazon.S3;
namespace ConsoleApplication1 {
class Program {
private const string accessKeyId = "YOURACCESSKEYIDHERE0";
private const string secretAccessKey = "YOURSECRETACCESSKEYHEREANDYESITSTHATLONG";
public static DateTime LocalNow() {
DateTime now = DateTime.Now;
return new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond, DateTimeKind.Local);
}
public static string SignRequest(string secret, string operation, DateTime timestamp) {
HMACSHA1 hmac = new HMACSHA1(Encoding.UTF8.GetBytes(secret));
string isoTimeStamp = timestamp.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ", CultureInfo.InvariantCulture);
string signMe = "AmazonS3" + operation + isoTimeStamp;
string signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(signMe)));
return signature;
}
static void Main(string[] args) {
DateTime now = LocalNow();
AmazonS3Client client = new AmazonS3Client();
var result = client.ListAllMyBuckets(
accessKeyId,
now,
SignRequest(secretAccessKey, "ListAllMyBuckets", now));
foreach (var bucket in result.Buckets) {
Console.WriteLine(bucket.Name);
}
}
}
}
If you now insert your access key ID and secret access key in the appropriate spots and run the program, you should get a listing of your S3 buckets.
The AmazonS3Client class has all the SOAP operations available as instance methods on it.
The Amazon website carries an older (VS2005 + WSE) C#/SOAP sample at http://developer.amazonwebservices.com/connect/entry.jspa?externalID=129&categoryID=47.
EDIT: posted a visual studio solution at http://flyingpies.wordpress.com/2009/08/04/the-shortest-ever-s3-csoapwcf-client/.
Wondering if anybody out there has any success in using the JDEdwards XMLInterop functionality. I've been using it for a while (with a simple PInvoke, will post code later). I'm looking to see if there's a better and/or more robust way.
Thanks.
As promised, here is the code for integrating with JDEdewards using XML. It's a webservice, but could be used as you see fit.
namespace YourNameSpace
{
/// <summary>
/// This webservice allows you to submit JDE XML CallObject requests via a c# webservice
/// </summary>
[WebService(Namespace = "http://WebSite.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class JdeBFService : System.Web.Services.WebService
{
private string _strServerName;
private UInt16 _intServerPort;
private Int16 _intServerTimeout;
public JdeBFService()
{
// Load JDE ServerName, Port, & Connection Timeout from the Web.config file.
_strServerName = ConfigurationManager.AppSettings["JdeServerName"];
_intServerPort = Convert.ToUInt16(ConfigurationManager.AppSettings["JdePort"], CultureInfo.InvariantCulture);
_intServerTimeout = Convert.ToInt16(ConfigurationManager.AppSettings["JdeTimeout"], CultureInfo.InvariantCulture);
}
/// <summary>
/// This webmethod allows you to submit an XML formatted jdeRequest document
/// that will call any Master Business Function referenced in the XML document
/// and return a response.
/// </summary>
/// <param name="Xml"> The jdeRequest XML document </param>
[WebMethod]
public XmlDocument JdeXmlRequest(XmlDocument xmlInput)
{
try
{
string outputXml = string.Empty;
outputXml = NativeMethods.JdeXmlRequest(xmlInput, _strServerName, _intServerPort, _intServerTimeout);
XmlDocument outputXmlDoc = new XmlDocument();
outputXmlDoc.LoadXml(outputXml);
return outputXmlDoc;
}
catch (Exception ex)
{
ErrorReporting.SendEmail(ex);
throw;
}
}
}
/// <summary>
/// This interop class uses pinvoke to call the JDE C++ dll. It only has one static function.
/// </summary>
/// <remarks>
/// This class calls the xmlinterop.dll which can be found in the B9/system/bin32 directory.
/// Copy the dll to the webservice project's /bin directory before running the project.
/// </remarks>
internal static class NativeMethods
{
[DllImport("xmlinterop.dll",
EntryPoint = "_jdeXMLRequest#20",
CharSet = CharSet.Auto,
ExactSpelling = false,
CallingConvention = CallingConvention.StdCall,
SetLastError = true)]
private static extern IntPtr jdeXMLRequest([MarshalAs(UnmanagedType.LPWStr)] StringBuilder server, UInt16 port, Int32 timeout, [MarshalAs(UnmanagedType.LPStr)] StringBuilder buf, Int32 length);
public static string JdeXmlRequest(XmlDocument xmlInput, string strServerName, UInt16 intPort, Int32 intTimeout)
{
StringBuilder sbServerName = new StringBuilder(strServerName);
StringBuilder sbXML = new StringBuilder();
XmlWriter xWriter = XmlWriter.Create(sbXML);
xmlInput.WriteTo(xWriter);
xWriter.Close();
string result = Marshal.PtrToStringAnsi(jdeXMLRequest(sbServerName, intPort, intTimeout, sbXML, sbXML.Length));
return result;
}
}
}
You have to send it messages like the following one:
<jdeRequest type='callmethod' user='USER' pwd='PWD' environment='ENV'>
<callMethod name='GetEffectiveAddress' app='JdeWebRequest' runOnError='no'>
<params>
<param name='mnAddressNumber'>10000</param>
</params>
</callMethod>
</jdeRequest>
To anyone trying to do this, there are some dependencies to xmlinterop.dll.
you'll find these files on the fat client here ->c:\E910\system\bin32
this will create a 'thin client'
PSThread.dll
icudt32.dll
icui18n.dll
icuuc.dll
jdel.dll
jdeunicode.dll
libeay32.dll
msvcp71.dll
ssleay32.dll
ustdio.dll
xmlinterop.dll
I changed our JDE web service to use XML Interop after seeing this code, and we haven't had any stability problems since. Previously we were using the COM Connector, which exhibited regular communication failures (possibly a connection pooling issue?) and was a pain to install and configure correctly.
We did have issues when we attempted to use transactions, but if you're doing simple single business function calls this shouldn't be an problem.
Update: To elaborate on the transaction issues - if you're attempting to keep a transaction alive over multiple calls, AND the JDE application server is handling a modest number of concurrent calls, the xmlinterop calls start returning an 'XML response failed' message and the DB transaction is left open with no way to commit or rollback. It's possible tweaking the number of kernels might solve this, but personally, I'd always try to complete the transaction in a single call.