Quantcast
Channel: Visual C# forum
Viewing all 31927 articles
Browse latest View live

Trouble Passing Array to Initialize Object Class

$
0
0

 Hello,

I am trying to test a DLL that I wrote and I'm having problems with the following initialization code:

        private void button1_Click(object sender, EventArgs e)
        {
            String[] sFieldList  = {"CustomerName", "CustomerAddress", "CustomerCityStateZip"};
            String[] sValues = {"Stuart Little", "1 Mouse Hole Drive", "Anytown, AS, 00000"};

            try
            {
               MWPOfficeUtils.WordDoc mwpDoc = new MWPOfficeUtils.WordDoc();

               mwpDoc.Merge("c:\\PolicyChange.dotx", "c:\\NewPolicyChange.html", sFieldList, sValues);
               MessageBox.Show("Document Created");
            }
            catch(System.Exception ex)
            {
                MessageBox.Show(ex.Message + " " + System.IO.Directory.GetCurrentDirectory());
            }

        }


When the code attempts to execute the mwpDoc.Merge method it throws the error:

"Index was outside the bounds of the array".  Any help that can be provided will be greatly appreciated.

Regards,

Matt Paisley

If it helps, the following is the code for the Class Library

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Outlook;
using Microsoft.Office.Interop.Word;

namespace MWPOfficeUtils
{
    public class WordDoc
    {
        public WordDoc()
        {

        }

        public void Merge(string pWordDoc, string pWordOutDoc, string[] pFields, string[] values)
        {
            Object oMissing = System.Reflection.Missing.Value;
            Object oTrue = true;
            Object oFalse = false;
            Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word._Document oWordDoc = new Microsoft.Office.Interop.Word.Document();
            oWord.Visible = false;
            Object oTemplatePath = pWordDoc;
                oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
            Microsoft.Office.Interop.Word.WdSaveFormat outHTML = WdSaveFormat.wdFormatHTML;

            //foreach (String pMergeField in pFields)

            for (int i = 0; i < pFields.Length; i++)
            {
                String pValue = values[i - 1];
                String pMergeField = pFields[i - 1];
                foreach (Microsoft.Office.Interop.Word.Field myMergeField in oWordDoc.Fields)
                {
                    Microsoft.Office.Interop.Word.Range rngFieldCode = myMergeField.Code;
                    String fieldText = rngFieldCode.Text;
                    if (fieldText.StartsWith(" MERGEFIELD"))
                    {
                        Int32 endMerge = fieldText.IndexOf("\\");
                        Int32 fieldNameLength = fieldText.Length - endMerge;
                        String fieldName = fieldText.Substring(11, endMerge - 11);
                        fieldName = fieldName.Trim();
                        if (fieldName == pMergeField)
                        {
                            myMergeField.Select();
                            oWord.Selection.TypeText(pValue);
                        }
                    }
                } //End foreach (Microsoft.Office.Interop.Word.Field myMergeField in oWordDoc.Fields)

            } // End for(int i = 0; i < pFields.Length; i++)
            oWordDoc.SaveAs2(pWordOutDoc, outHTML);
            oWordDoc.Close();
            oWord.Quit();

        } // End Method: Merge

        public void MergePDF(string pWordDoc, string pWordOutDoc, string[] pFields, string[] values)
        {
            Object oMissing = System.Reflection.Missing.Value;
            Object oTrue = true;
            Object oFalse = false;
            Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word._Document oWordDoc = new Microsoft.Office.Interop.Word.Document();
            oWord.Visible = false;
            Object oTemplatePath = pWordDoc;
            oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
            Microsoft.Office.Interop.Word.WdSaveFormat outHTML = WdSaveFormat.wdFormatHTML;

            //foreach (String pMergeField in pFields)

            for (int i = 0; i < pFields.Length; i++)
            {
                //String pValue = values[i-1];
                //String pMergeField = pFields[i-1];
                String pValue = values[i - 1];
                String pMergeField = pFields[i - 1];
                foreach (Microsoft.Office.Interop.Word.Field myMergeField in oWordDoc.Fields)
                {
                    Microsoft.Office.Interop.Word.Range rngFieldCode = myMergeField.Code;
                    String fieldText = rngFieldCode.Text;
                    if (fieldText.StartsWith(" MERGEFIELD"))
                    {
                        Int32 endMerge = fieldText.IndexOf("\\");
                        Int32 fieldNameLength = fieldText.Length - endMerge;
                        String fieldName = fieldText.Substring(11, endMerge - 11);
                        fieldName = fieldName.Trim();
                        if (fieldName == pMergeField)
                        {
                            myMergeField.Select();
                            oWord.Selection.TypeText(pValue);
                        }
                    }
                } //End foreach (Microsoft.Office.Interop.Word.Field myMergeField in oWordDoc.Fields)

            } // End for(int i = 0; i < pFields.Length; i++)
            oWordDoc.SaveAs2(pWordOutDoc, outHTML);
            oWordDoc.Close();
            oWord.Quit();
        } // End Method: Merge

    }  // End class WordDoc
}

COM Type Library - How to make hidden

$
0
0

How can you mark a COM type library created in C# as hidden? Is there some attribute available for this?  In other words, I'm look for behavior such as is available with the following IDL code:

[
	object,
	uuid(81D5DC7F-C4AA-43CD-9024-8D304F3C9DFC),
	dual,
	nonextensible,
	pointer_default(unique)
]
[
	uuid(C2D91F4D-2FCA-4243-9E37-B21D97C0954C),
	version(1.0),
	hidden					// This should hide the TLB from browsers
]
library HiddenTLBLib
{
	importlib("stdole2.tlb");
};

I need it as some attribute so that when the assembly is distributed to other systems (through Windows Installer), it is properly marked as hidden in the registry on type library registration.

Thanks

Image callback c++ to c#

$
0
0

I have the following problem: I have a method in a c++ dll that uses some code from a hardware developer that captures an image in a "BITMAPINFO * info;"

http://msdn.microsoft.com/en-us/library/windows/desktop/dd183375%28v=vs.85%29.aspx

know I have to send it to a c# class that uses it, so I must send a callback to the c# class, right know I solve the problem sending the image to a file and reading the file form the C# class but I know it is not the correct form to do it.

If someone knows how I can convert the bitmapinfo * to a byte * or how to implement the callback for a bitmapinfo to a managed code in c# it would be great.

Tanks for the time and sorry for my English ;)

char ** cpp dll to c#

$
0
0

 have the following problem:

I need to make use of a third party dll written c++ in with my c# code.

I have done a lot of work using the dll export but I am stuck because the method receives a char **.

When dealing with a char * I can use a ref byte, but I don't know what to do with a char **.

How can i make use of this dll?

CPP CODE:

MYAPI int WINAPI Do_Work( unsigned char ** i_puc_Buffer,unsigned short i_us_numberTemplates)
{
    int i = 0;
    C_Device m_x_Device;
    int res = m_x_Device.OpenDevice(-1);
    if (res != OK)
    {
       Beep(BEEP_FREQUENCY - 300, BEEP_DURATION + 400);
       return res;
    }
    else
    {
        C_TemplateList  l_x_Template;
        for (i = 0; i < i_us_numberTemplates; i++)
        {
           l_i_Ret = l_x_Template.PutTemplate(
           i_us_BufferLength[i],
           i_puc_Buffer[i]
           );
           if (l_i_Ret != OK)
           {
                m_x_Device.CloseDevice();
                Beep(BEEP_FREQUENCY, BEEP_DURATION * 2);
                return l_i_Ret;
            }
         }
         m_x_Device.CloseDevice();
         Beep(BEEP_FREQUENCY, BEEP_DURATION);
         Beep(BEEP_FREQUENCY, BEEP_DURATION);
         return 0;
        }
        return(res);
       };

in my C# code

[DllImport("MyDll.dll", CallingConvention = CallingConvention.StdCall)]
private static extern int Do_Work(ref byte []i_puc_Buffer,short i_us_numberTemplates);



When to not use dynamic in C#

$
0
0

I'm making a class similar to the following:

publicclassKeyValue{publicreadonlystring key;publicreadonlyobject value;}

Value could be of any object type as a result of this design.

Alternatively, I could just use dynamic for value and it'll make my life easier, because it would mean no type-casting, and also because, as far as I understand, I could use value types without needing to box/unbox.

Is there any reason not to use dynamic and to use object instead? Because I can't think of any.

Note: I realize generics are much more suited for this, but it doesn't work for my needs. The above is really a simplification just for the purposes of this question.

Overload method using decimal and int?

$
0
0

I am just wondering if anyone ever ran into the problem when overloading a method using paramters of type decimal and int? as in the example below:

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            TestClass myClass = new TestClass();

            decimal d = (decimal)1.1;
            int i = 1;

            Console.WriteLine("Result 1 = {0}", myClass.TestMethod(d, d, i));
            Console.WriteLine("Result 2 = {0}", myClass.TestMethod(d, i, i));
            Console.ReadKey();
        }
    }

    public class TestClass
    {
        public string TestMethod(decimal test1, decimal test2, int? test3)
        {
            return "Method overload 1";
        }

        public string TestMethod(decimal test1, int? test2, int? test3)
        {
            return "Method overload 2";
        }
    }
}

Anybody have an idea how to work around this problem. In my 'real' code where I ran into this problem I created a second method with a different name to resolve the issue.

Cheers,

Pieter

Object Reference not set to an instance of an object

$
0
0

I am working on a windows form application in visual studio 2012. I downloaded dll for webcam from easywebcam.codeplex.com. I also added references to the dll libraries provided by easywebcam. The webcam works great at first attempt but when it's rebuild then I get the following error.
An error occurred while capturing the video image. The video capture will now be terminated.

Object reference not set to an instance of an object.

Webcamm Class

    private WebCamCapture webcam;
        private System.Windows.Forms.PictureBox _FrameImage;
        private int FrameNumber = 30;
        public void InitializeWebCam(ref System.Windows.Forms.PictureBox ImageControl)
        {
            webcam = new WebCamCapture();
            webcam.FrameNumber = ((ulong)(0ul));
            webcam.TimeToCapture_milliseconds = FrameNumber;
            webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
            _FrameImage = ImageControl;
        }

        void webcam_ImageCaptured(object source, WebcamEventArgs e)
        {
            
            _FrameImage.Image = e.WebCamImage;
        }

        public void Start()
        {
            webcam.TimeToCapture_milliseconds = FrameNumber;
            webcam.Start(0);//error on this line
        }

Main Form or Form1

 Webcamm wbcam;
        public Form1()
        {
            InitializeComponent();
            wbcam = new Webcamm();
            wbcam.InitializeWebCam(ref pictureBox1); //webcam=Could not evaluate the expression but  application builds
        }
        private void button3_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = pictureBox2.Image;
            helper.saveCaptureImage(pictureBox2.Image);
        }
        private void button5_Click(object sender, EventArgs e)
        {
            wbcam.Stop();
        }

        private void btn_Start_Click(object sender, EventArgs e)
        {

            wbcam.Start();
        }



Datetime difference is seconds

$
0
0

This is my code:

timeAlive = datetime_comes_from_db;
TimeSpan timeDiff = DateTime.Now - timeAlive;

if (timeDiff.TotalSeconds < 10)
{

For example if it's 12 o'clock and the retrieved value is 10:00 then i want the timeDiff.TotalSeconds to be 7200 seconds since 60sec * 60mins *2 hours. The above doen't work. 


convert from visual studio to c#

$
0
0

bmpTile = new Bitmap(GFX.pbGFX.Image)

How would i do this in c#. its the GFX am getting the error at




I created a picture box variable and did this
bmpTile = new Bitmap(GFX.Image);

is this correct

How to allow only single byte in the textbox for entering

$
0
0

HI Experts,

Could you please provide snippet of code for allowing the textbox for entering only 

single byte using Uniform resource identifier (URI)(ABNF for URI of the following RFC).

http://tools.ietf.org/html/rfc3986

Thanks in advance.


WPF How can i add progressbar that can load my files..

$
0
0

how can i  add progressbar to my wpfForm that can load/Read my files,DLL etcc.....

can i use if statement?..


WebClient.DownloadData encounterred errors

$
0
0

Hi,

I am using WebClient.DownloadData(string) in 4 Threads to download the web page content. Each thread owns its independent WebClient object, means not shared among threads. When I run the code, some of the threads fail to download the data and encounter an error, while others complete successfully.

The error is

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
   --- End of inner exception stack trace ---
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadData(Uri address)

I am confusing that why some threads can complete the request successfully, but some cannot. Thanks.

Unzip .mdb file in c#

$
0
0

I can download my .mdb file from server but it can't extract file correctly. There is always an error shown saying that the file was corrupt. I got set password access for my .mdb file

Thanks

Loosing precision while reading the values from Excel in C#

$
0
0

I need to read the values from excel sheet using c# - OleDB connection. Excel sheet has both numeric values and percentage values.

The excel cell has the value as 0.25%.

But the actual value of the cell is 0.247337730504847%

While reading the values using OleDB connection, my DataSet gives me 0.25% instead of 0.247337730504847%

Please help.

Below is the connection string used to read the excel file.

connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;
                                  Data Source="+ filelocation +@";Extended Properties=""Excel 8.0;IMEX=1;HDR=NO""";

My excel sheet also has some cells with 'Accounting' formating. I need to read those values. So I have used IMEX=1.

I need to full precision on numeric values as well as need to read accounting formatted cells.

please help

DataTable item removal

$
0
0

So I come from a background where I live and die by pointers to get me to a specific data item.  I am use to deleting a specific item very easily and very fast by using a pointer to remove the item or when I use an unbound grid I can remove the data and remove the item in the grid with two lines of code.  Using .Net I know you can remove an item based on it's index array and that works ok until and item is removed and now all the index arrays change dynamically. So when moving multiple items it can cause many issues. 

With that being said why is there no easy method of removing an item from a data table without creating a class that loops through each datarow in the datatable and looks for s specific item you want to delete.  Seems very silly to me to loop through 200,000 rows to look for an item to remove. Is there no way that has very little overhead to remove a specific item with a unique primary key without looping through the entire collection or until it finds a match to remove.

Thanks in advance 


Associating one class with another class

$
0
0

Is embedding Type property inside a class a good way to associate it with another class? (like itself indicating "Hey I belong to that class over there")


I  have a large setting configuration that defines 5 settings, each for working on 5 different object types

I was thinking of embedding a Type property inside the settings class that indicates the exact Type of object it refers to

Like:

SettingsClass1 : ISettings {

   ...

   public Type ObjectTypeIBelongTo {get {return typeOf(ConcreteObject1); }}

}

SettingsClass2 : ISettings {

   ...

   public Type ObjectTypeIBelongTo {get {return typeOf(ConcreteObject2); }}

}


Class ConcreteObject1 : IConcreteObject{

}

Class ConcreteObject2 : IConcreteObject{

}

...

And then I was thinking of creating a Dictionary that contains the setting and the typeName it refers to like

Dictionary<string, ISettings> mappings;

where string would be the name of the Type ObjectTypeIBelongTo

So whenever I encountered an IConcreteObject, I can immediately pull the appropriate settings fom the dictionary by doing

IConcreteObject ConcObj = new ConcreteObject1();

string concreteObjectName = ConcObj.GetType().Name;

ISettings setting = mappings[concreteObjectName];

**The only problem I can see is that my solution only tells you who belongs to who and doesn't really enforce it strongly enough.  Like nothing is preventing the user to match the wrong setting class with the concreteObject class. Although if this is internal structure of an API that is not exposed to end user, would it still be acceptable?

Parse nested XML

$
0
0

Hi

I wanted to parse and find XML node having specific value. For e.g. in below xml document I wanted to find the UIObject node havign Id= 'UIEnterpirseIDEdit'

Xml structure is fixed but UIObject level might differ. ie. it might be  under node UIobject having id 'UIEnterpirseIDEdit'

how to get element this xml element in C#

Thanks

Varsha

<?xml version="1.0"?><UITest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="" Id="b267ee5a-a190-4e90-aa2a-ffd0207de69b" AssemblyVersion="11.0.61030.0" Version="1.0" xmlns="http://schemas.microsoft.com/VisualStudio/TeamTest/UITest/2010"><Configuration><Group Name="IE"><Setting Name="Version" Value="9.11.9600.17501" WarningLevel="1" /><Setting Name="InformationBar" WarningLevel="1" /><Setting Name="AutoCompletePassword" WarningLevel="1" /><Setting Name="AutoCompleteForm" Value="no" WarningLevel="1" /><Setting Name="DefaultBrowser" Value="IEXPLORE.EXE" WarningLevel="1" /><Setting Name="PopupBlocker" Value="0" WarningLevel="1" /><Setting Name="TabbedBrowsing" WarningLevel="2" /><Setting Name="InternetZoneSecurity" Value="0" WarningLevel="2" /><Setting Name="IntranetZoneSecurity" Value="69632" WarningLevel="2" /><Setting Name="TrustedZoneSecurity" Value="70912" WarningLevel="2" /><Setting Name="RestrictedZoneSecurity" Value="73728" WarningLevel="2" /><Setting Name="PhishingFilter" WarningLevel="1" /><Setting Name="EnhancedSecurityConfiguration" Value="0" WarningLevel="1" /></Group><Group Name="OS"><Setting Name="Name" Value="Microsoft Windows Server 2008 R2 Enterprise " WarningLevel="2" /><Setting Name="Version" Value="Microsoft Windows NT 6.1.7601 Service Pack 1" WarningLevel="2" /><Setting Name="IsUserAdmin" Value="True" WarningLevel="2" /><Setting Name="Is64BitOperatingSystem" Value="True" WarningLevel="2" /><Setting Name="IsTerminalServerSession" Value="True" WarningLevel="2" /><Setting Name="OSLanguage" Value="1033" WarningLevel="1" /><Setting Name="UserLocale" Value="1033" WarningLevel="1" /><Setting Name="DragFullWindows" Value="False" WarningLevel="2" /><Setting Name="ScreenResolutionWidth" Value="1280" WarningLevel="2" /><Setting Name="ScreenResolutionHeight" Value="1024" WarningLevel="2" /><Setting Name="SystemDPIX" Value="96" WarningLevel="2" /><Setting Name="SystemDPIY" Value="96" WarningLevel="2" /><Setting Name="Aero" Value="1" WarningLevel="1" /><Setting Name="UACEnabled" Value="0" WarningLevel="2" /><Setting Name="UACPromptEnabled" Value="0" WarningLevel="1" /></Group><Group Name="TechnologyManagers" /></Configuration><InitializeActions /><CleanupActions /><OnErrorActions /><Maps><UIMap Id="UIMap"><TopLevelWindows><TopLevelWindow ControlType="Window" Id="UIAUGConnectInternetExWindow" FriendlyName="AUG Connect... - Internet Explorer" SpecialControlType="BrowserWindow" SessionId="853230"><TechnologyName>MSAA</TechnologyName><WindowTitles><WindowTitle>AUG Connect...</WindowTitle></WindowTitles><SearchConfigurations><SearchConfiguration>VisibleOnly</SearchConfiguration></SearchConfigurations><AndCondition Id="SearchCondition"><PropertyCondition Name="Name">AUG Connect...</PropertyCondition><PropertyCondition Name="ClassName">IEFrame</PropertyCondition><PropertyCondition Name="ControlType">Window</PropertyCondition></AndCondition><SupportLevel>0</SupportLevel><Descendants><UIObject ControlType="Document" Id="UIAUGConnectDocument" FriendlyName="AUG Connect..." SpecialControlType="None"><TechnologyName>Web</TechnologyName><WindowTitles><WindowTitle>AUG Connect...</WindowTitle></WindowTitles><AndCondition Id="SearchCondition"><AndCondition Id="Primary"><PropertyCondition Name="ControlType">Document</PropertyCondition><PropertyCondition Name="TagName">BODY</PropertyCondition><PropertyCondition Name="Id" /><PropertyCondition Name="RedirectingPage">False</PropertyCondition><PropertyCondition Name="FrameDocument">False</PropertyCondition></AndCondition><FilterCondition Id="Secondary"><PropertyCondition Name="Title">AUG Connect...</PropertyCondition><PropertyCondition Name="AbsolutePath">/aug/</PropertyCondition><PropertyCondition Name="PageUrl"></PropertyCondition></FilterCondition></AndCondition><SupportLevel>0</SupportLevel><Descendants><UIObject ControlType="Edit" Id="UIEnterpriseIdEdit" FriendlyName="Enterprise Id :" SpecialControlType="None"><TechnologyName>Web</TechnologyName><WindowTitles><WindowTitle>AUG Connect...</WindowTitle></WindowTitles><AndCondition Id="SearchCondition"><AndCondition Id="Primary"><PropertyCondition Name="ControlType">Edit</PropertyCondition><PropertyCondition Name="TagName">INPUT</PropertyCondition><PropertyCondition Name="Id">ContentPlaceHolder1_LoginAUG_UserName</PropertyCondition><PropertyCondition Name="Name">ctl00$ContentPlaceHolder1$LoginAUG$UserName</PropertyCondition></AndCondition><FilterCondition Id="Secondary"><PropertyCondition Name="LabeledBy">Enterprise Id :</PropertyCondition><PropertyCondition Name="Type">SINGLELINE</PropertyCondition><PropertyCondition Name="Title" /><PropertyCondition Name="Class" /><PropertyCondition Name="ControlDefinition">name="ctl00$ContentPlaceHolder1$LoginAUG</PropertyCondition><PropertyCondition Name="TagInstance">3</PropertyCondition></FilterCondition></AndCondition><SupportLevel>0</SupportLevel><Descendants /></UIObject><UIObject ControlType="Edit" Id="UIPasswordEdit" FriendlyName="Password :" SpecialControlType="None"><TechnologyName>Web</TechnologyName><WindowTitles><WindowTitle>AUG Connect...</WindowTitle></WindowTitles><AndCondition Id="SearchCondition"><AndCondition Id="Primary"><PropertyCondition Name="ControlType">Edit</PropertyCondition><PropertyCondition Name="TagName">INPUT</PropertyCondition><PropertyCondition Name="Id">ContentPlaceHolder1_LoginAUG_Password</PropertyCondition><PropertyCondition Name="Name">ctl00$ContentPlaceHolder1$LoginAUG$Password</PropertyCondition></AndCondition><FilterCondition Id="Secondary"><PropertyCondition Name="LabeledBy">Password :</PropertyCondition><PropertyCondition Name="Type">PASSWORD</PropertyCondition><PropertyCondition Name="Title" /><PropertyCondition Name="Class" /><PropertyCondition Name="ControlDefinition">name="ctl00$ContentPlaceHolder1$LoginAUG</PropertyCondition><PropertyCondition Name="TagInstance">4</PropertyCondition></FilterCondition></AndCondition><SupportLevel>0</SupportLevel><Descendants /></UIObject><UIObject ControlType="Button" Id="UICtl00ContentPlaceHolButton" FriendlyName="ctl00$ContentPlaceHolder1$LoginAUG$LoginImageButto..." SpecialControlType="None"><TechnologyName>Web</TechnologyName><WindowTitles><WindowTitle>AUG Connect...</WindowTitle></WindowTitles><AndCondition Id="SearchCondition"><AndCondition Id="Primary"><PropertyCondition Name="ControlType">Button</PropertyCondition><PropertyCondition Name="TagName">INPUT</PropertyCondition><PropertyCondition Name="Id">ContentPlaceHolder1_LoginAUG_LoginImageButton</PropertyCondition><PropertyCondition Name="Name">ctl00$ContentPlaceHolder1$LoginAUG$LoginImageButton</PropertyCondition></AndCondition><FilterCondition Id="Secondary"><PropertyCondition Name="DisplayText" /><PropertyCondition Name="Type">image</PropertyCondition><PropertyCondition Name="Src"></PropertyCondition><PropertyCondition Name="Title" /><PropertyCondition Name="Class" /><PropertyCondition Name="ControlDefinition">name="ctl00$ContentPlaceHolder1$LoginAUG</PropertyCondition><PropertyCondition Name="TagInstance">5</PropertyCondition></FilterCondition></AndCondition><SupportLevel>0</SupportLevel><Descendants /></UIObject></Descendants></UIObject></Descendants></TopLevelWindow></TopLevelWindows></UIMap></Maps><ValueMap><ParameterList /></ValueMap></UITest>

c# read data from remote PLC with CC link IE control

$
0
0

This is the first time for me in this application. link library is only for VC++, so I wrapped it into a library that can use in c#, and then import in c#, I 've tested the function in VC++ it works fine.but in C#, although the return value is 0, I can read nothing, the result is null. hope somebody can help me. thanks in advance.

here is the function in original library header file.

LONG WINAPI mdReceiveEx( LONG, LONG, LONG, LONG, LONG, LPLONG, LPVOID );

and I wrapped in C++

MELFUNC_API long MmdReceiveEx(long path,long netno,long stno,long devtyp,long devno,long size,short *data);long MmdReceiveEx(long path,long netno,long stno,long devtyp,long devno,long size,short *data)// {
long result=mdReceiveEx(path,netno,stno,devtyp,devno,&size,data);
return result; }

and import in c#

[DllImport(@dllname, CallingConvention = CallingConvention.Cdecl)]

static extern int MmdReceiveEx(int path, int netno, int stno, int devtyp, int devno, short size, ref short[] data);

and the function be called

int retval2 = MmdReceiveEx(151, 1, 2, 23, 0x00, sizetst, ref buf1);

the retval2 will be 0 and buf1 be null after executed. can anybody help me?

Problems registering Visual C# 2008 Express Edition

$
0
0

I've recently installed and have been using Visual C# 2008 Express, but now it is forcing me to register to continue to use it.

OK, so I've now created and verified a Microsoft account, but when I click the "register now" link on the startup screen I get an error from the web browser: We are sorry, the page you requested cannot be found

How can I get a registration key so I can continue to use this? I know there are later versions but it's what others in my team have used in the past to develop code and I need to be compatible with their previous work. 

passing variable to other form

$
0
0



hey guy's im doing a school project and im stuck on this issue..

i need to make a ATM machine simulator..lol

i got the pin all is done it needs to look in a TXT file for a corresponding NIP.file auth.thx

so that part is ok but when i get to the second menu ,Main menu i need to output the name associated with the NIP in the Auth.thx file and look in accounts.
txt for the client info

account number,NIP,$$...

so my question is in my auth.txt i have Name:me NIP:1234

so the search finds the NIP but can i output the name and keep it in a variable for all the other forms and menu items?or if i put the form in relation with the login? main : login
Viewing all 31927 articles
Browse latest View live