Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

marca292

@marca292
About
Posts
50
Topics
31
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Loading dll and resources from wrong folder
    M marca292

    Thanks for all help. I got this working. The problem was timing problem in the 3rd party dll's. AppA is starting appB in a sandbox and adds overhead (=> timing problem). Because of this timeing problem a exception was throwed before all dll:s were loaded. (difficult to give a precise explanation of a few short lines here)

    .NET (Core and Framework) csharp question help workspace

  • Loading dll and resources from wrong folder
    M marca292

    Yes but is is still not working. From AppB i print System.IO.Directory.GetCurrentWorkingDirectory() and that path is alright. I Also print all loaded dll:s and when AppB is started through Process:Start, some dlls are not loaded

    .NET (Core and Framework) csharp question help workspace

  • Loading dll and resources from wrong folder
    M marca292

    I have two C# .NET applications, AppA (located in folder A) and AppB (located in folder B). AppB is also using a lot of 3rd party dll:s and configuration files located in folder B. If I start AppB from folder B the application is working as expected. The problem is when I start appB from appA using Process.Start(), and Process.StartInfo.FileName is pointing to appB. AppB is now starting up, but it seems like it is trying to load resources from folder A instead of folder B. How can I solve this? appB shall always load resources and dll:s from folder B.

    .NET (Core and Framework) csharp question help workspace

  • app.config
    M marca292

    I am using a app.config to load dll from other folders than my applications bin folder. Now I can load all the dll:s my application need at startup. The problem is that my application is using another dll when the user presses a button. Can I load this dll using the app.config?

    Thanks

    .NET (Core and Framework) help question

  • Assembly with different .NET framework versions
    M marca292

    I have a assembly A that must use .NET framework 3.5. This assembly has a referense to a 3rd party assembly that has been developed with .net framework 4.0. The problem is that I can't build because the 3rd party uses FW 4.0. Is it possible to solve this?

    .NET (Core and Framework) csharp dotnet help question

  • Dll problem
    M marca292

    I have a C# application that tests a product my company developes. At the moment this application can be run on a ordinary laptop. I have now started to develope new tests that requires specific hardware and dll:s. These new tests can only be run on a computer that has this hardware installed. What is the best solution if I still want to be able to use the same application on an ordinary laptop to run the other tests that don't requires the new hardware? The "ordinary laptop" is missing the dll:s that my application is using to communicatio with the hardware.

    C# question csharp hardware help

  • Comma separeted text file
    M marca292

    Hi, I have a comma separated text file and I want to get all SerialNumber for a specific device. Example: I want to get the SerialNumber for all Device:A1 => 345 and 347

    ID:432,Name:Jones,SerialNumber:345,Device:A1
    ID:432,Name:Mark,SerialNumber:347,Device:A1
    ID:432,Name:Ann,SerialNumber:346,Device:A2

    I have now solved this problem with a combination of linq, foreach and regex. How can I do this in one linq expression? Best regards Olof

    LINQ question csharp linq regex help

  • Leap year algorithm
    M marca292

    Hi, I want to have a fast algorithm to determine if it’s leap year, is this a good one?

    bool isLeapYear(int year)
    {
    bool leapYear = year%4 == 0 && (year %100 != 0 || year%400 == 0;
    return leapYear;
    }

    Thanks!

    C / C++ / MFC algorithms question

  • Convert bits to bytes
    M marca292

    Hi, In a C++ software projetc I'm working with they gets

    number of bytes = ((number of bits)* 7) / 8

    Why isn't

    number of bytes = (number of bits) / 8

    Thanks!

    Algorithms c++

  • Remove warning "unused parameters"
    M marca292

    Thanks!!

    C / C++ / MFC c++ design help question

  • Remove warning "unused parameters"
    M marca292

    I have a C++ class that implements a interface (ErrorInterface), because of old design. My class don't uses one of the methods (reset) in this interface but I have added an empty implementation because I don't want the class to be abstract. When I build the project I get warnings "unused parameters 'error'". Can I remove this warning?

    //Interface
    class ErrorInterface
    {
    public:
    virtual void reset(ErrorType error) = 0;
    };

    //.cpp file I have just added the implementation
    //because I don't want MyClass to be abstract
    void MyClass::reset(ErrorType error)
    {
    }

    C / C++ / MFC c++ design help question

  • Problem declaring data type
    M marca292

    I use this solution, then it's working.

    C / C++ / MFC question c++ help

  • Problem declaring data type
    M marca292

    Yes.

    C / C++ / MFC question c++ help

  • Problem declaring data type
    M marca292

    I already include that header file

    C / C++ / MFC question c++ help

  • Problem declaring data type
    M marca292

    Hi, I'm working with a C++ project and have created a new .h file that contains typedef of new types. How do I use the new types in another class?

    #ifndef COMMONSETTINGS_H_
    #define COMMONSETTINGS_H_

    typedef enum
    {
        XX = 0,
        YY,
        ZZ
    } ProductType;
    

    #endif /* COMMONSETTINGS_H_ */

    And the class that uses the type ProductType

    class TestClass
    {
    public:
    //! Constructor
    TestClass();

    //! Desctructor
    virtual ~TestClass();
    

    private:
    ProductType product;
    };

    How do I do to use ProductTyp in TestClass? Now I get compile erro since TestClass can not find ProductType. What is the best way to solve this? I want to declare new types in a file and use the types in several other classes. /Olof

    C / C++ / MFC question c++ help

  • GetThreadPreferredUILanguages
    M marca292

    Hi, I need to get all installed languages on the computer. "Control Panel / Regional and Language / Keyboards and Languages / Display language". How can I get the selected language in .NET? Our application has language settings for a lot of different languages. If our application don't has support for the selected language in "Display language" then we have to see if we has support for a fallback language. I tried to use "GetThreadPreferredUILanguages" call and it work fine when I use C++, but I can't get is working on .NET. Is there an .NET call I can use instead to get selected languages and also the fallback languages? C++ code

    wchar\_t buf\[2323\];
    
    wchar\_t \*pBuf;
    
    ULONG numLangs;
    
    ULONG size= 2323;
    
    
    
    GetThreadPreferredUILanguages(MUI\_MERGE\_USER\_FALLBACK, &numLangs, buf, &
    

    C# code

    [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

        static extern System.Boolean GetThreadPreferredUILanguages(
    
            System.UInt32 dwFlags,
    
            ref System.UInt32 pulNumLanguages,
    
            **out** System.IntPtr pwszLanguagesBuffer,
    
            ref System.UInt32 pcchLanguagesBuffer
    
            );
    
    
    
    
    
          uint MUI\_MERGE\_USER\_FALLBACK = 0x20;
    
            uint numLang = 0;
    
            IntPtr pwszLangBuf = new IntPtr();
    
            uint langBuf = 2323;
    
            bool b = GetThreadPreferredUILanguages(MUI\_MERGE\_USER\_FALLBACK, ref numLang, out pwszLangBuf, ref langBuf);
    
    
    
            string tmp = Marshal.PtrToStringAuto(pwszLangBuf
    

    tmp string variable contains only a lot of chinese characters after Marshal.PtrToStringAuto(pwszLangBuf);. pulNumLanguages and pcchLanguagesBuffer returns the same in both C++ and C#. See more information about GetThreadPreferredUILanguages on http://msdn.microsoft.com/en-us/library/dd318128(v=vs.85).aspx[^] What is wrong? Regards Olof

    C# question csharp c++ visual-studio com

  • Unmanaged dll call from C#, AccessViolationExceptionMessage [modified]
    M marca292

    I was just wondering if anyone could see something wrong with my C# struct declaration that could cause this error. Maybe, I shall see if I can get hold of the people who created this dll.

    C# csharp c++ help visual-studio performance

  • Unmanaged dll call from C#, AccessViolationExceptionMessage [modified]
    M marca292

    Yes, fnMGetApnData() is the unmanaged call to the dll. I don't have the source code to this dll. I tried to debug this unmanaged call in the assembler code but have not enought assembler experience. The only thing I can see is that a assembler "call" is causing the exception.

    C# csharp c++ help visual-studio performance

  • Unmanaged dll call from C#, AccessViolationExceptionMessage [modified]
    M marca292

    Hi, I am calling a .dll from C#. There is no problem loading the dll and call some functions from C#, but one function call gives "System.AccessViolationExceptionMessage: Attempted to read or write protected memory. This is often an indication that other memory is corrupt." There is no problem to call this function from c++. I suppose something is wrong with the structures I use in C# but I'm not sure what and how to solve this issue. Using Visual Studio 2008. ********************************** C++ **********************************

    typedef enum _MAPI_APN_TYPE
    {
    MAPI_APN_PRIMARY = 0,
    MAPI_APN_ACTIVATION,

    }MAPI_APN_TYPE;

    typedef struct _MAPI_APN_DATA
    {
    wchar_t wcApn[80];
    wchar_t wcUsername[80];
    wchar_t wcPassword[80];
    wchar_t wcDialNumber[80];

    }MAPI_APN_DATA, * LPMAPI_APN_DATA;

    typedef struct _MAPI_CORE_PATH
    {
    wchar_t strPath [ 260 ];

    }MAPI_CORE_PATH, *LPMAPI_CORE_PATH;

    ***** c++ function that works: *******
    MAPI_APN_DATA data;
    MAPI_CORE_PATH path;
    memset( &path, 0, sizeof( MAPI_CORE_PATH ) );
    result = M_API_GetApnData( &path, MAPI_APN_ACTIVATION, &data );

    ********************************** C# **********************************

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public struct MAPI_APN_DATA
    {
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
    public string apn;

    \[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)\]
    public string username;
    
    \[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)\]
    public string password;
    
    \[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)\]
    public string dialNumber;
    

    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public struct MAPI_CORE_PATH
    {
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
    public string strPath;
    }
    public enum MAPI_APN_TYPE
    {
    MAPI_APN_PRIMARY = 0,
    MAPI_APN_ACTIVATION,
    };

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    private delegate MAPI_RESULT M_API_GetApnData(ref MAPI_CORE_PATH path, MAPI_APN_TYPE apn_type, ref MAPI_APN_DATA data);
    private M_API_GetApnData fnMGetApnData;

    //Init function delegates
    pFunction = MbmFramework.Native.GetProcAddress(pMClientDll, "M_API_GetApnData");
    fnMGetApnData = (M_API_GetApnData)Marshal.GetDelegateForFunctionPointer(pFunction, typeof(M_API_GetApnData));

    //And the method that calls fnMGetApnData and gives System.AccessViolationExceptionMessage
    MAPI_APN_DATA data = new MAPI_APN_DATA();
    MAPI_CORE_PATH path = new MAPI_CORE_PATH

    C# csharp c++ help visual-studio performance

  • See if dll exist
    M marca292

    Of cours not, are you stupid or??? It very difficult to know when the user puts the system into sleep. And I don't see the meaning of your comment, you have no idea how big our application is and how it work. The application stops working ~1/100 sleep resume tests. Thanks for your answer!

    C / C++ / MFC question c++
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups