Click here to Skip to main content
15,889,858 members
Home / Discussions / C#
   

C#

 
QuestionI wants to convert a string to an array of bytes using UTF-8 encoding and write it to a file, which of the following code should be use ? Pin
Member 1309368221-Sep-17 22:59
Member 1309368221-Sep-17 22:59 
AnswerRe: I wants to convert a string to an array of bytes using UTF-8 encoding and write it to a file, which of the following code should be use ? Pin
Eddy Vluggen21-Sep-17 23:15
professionalEddy Vluggen21-Sep-17 23:15 
AnswerRe: I wants to convert a string to an array of bytes using UTF-8 encoding and write it to a file, which of the following code should be use ? Pin
OriginalGriff21-Sep-17 23:18
mveOriginalGriff21-Sep-17 23:18 
AnswerRe: I wants to convert a string to an array of bytes using UTF-8 encoding and write it to a file, which of the following code should be use ? Pin
Jochen Arndt22-Sep-17 0:17
professionalJochen Arndt22-Sep-17 0:17 
GeneralRe: I wants to convert a string to an array of bytes using UTF-8 encoding and write it to a file, which of the following code should be use ? Pin
Rob Philpott22-Sep-17 0:19
Rob Philpott22-Sep-17 0:19 
GeneralRe: I wants to convert a string to an array of bytes using UTF-8 encoding and write it to a file, which of the following code should be use ? Pin
Jochen Arndt22-Sep-17 0:23
professionalJochen Arndt22-Sep-17 0:23 
GeneralRe: I wants to convert a string to an array of bytes using UTF-8 encoding and write it to a file, which of the following code should be use ? Pin
Rob Philpott22-Sep-17 1:15
Rob Philpott22-Sep-17 1:15 
QuestionImplementing a COM Message Filter, it always fails... Pin
Joan M21-Sep-17 5:57
professionalJoan M21-Sep-17 5:57 
Hi all,

In my first C# console application I want to avoid COM problems and therefore I'm registering the IOleMessageFilter to handle any threading errors.

Well this wouldn't be a question without the problem part so here we go:

C#
public static void Register()
    {
      IOleMessageFilter newFilter = new MessageFilter();
      IOleMessageFilter oldFilter = null;
      int test = CoRegisterMessageFilter(newFilter, out oldFilter);

      if (test != 0)
        Debug.Fail("CoRegisterMessageFilter failed!");
      else
        _isRegistered = true;
    }


This never goes past the Debug.Fail, but I can't understand why as the message is not very explanatory by itself:

---------------------------
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue
---------------------------
CoRegisterMessageFilter failed!

   at SysConfig.MessageFilter.Register() in c:\...\MessageFilter.cs:line 42
   at SysConfig.DTE.CreateDTE(Boolean ideVisible, Boolean suppressUI, Boolean userControl) in c:\...\DTE.cs:line 50
   at SysConfig.Program.SysConfigM(Int32 i) in c:\...\Program.cs:line 163
   at SysConfig.Program.SetNumberOfM() in c:\...\Program.cs:line 136
   at SysConfig.Program.MenuHandler() in c:\...\Program.cs:line 48
   at SysConfig.Program.Main(String[] args) in c:\...\Program.cs:line 26
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
---------------------------


What could happen?, searching about CoRegisterMessageFilter is very fun as it doesn't show a lot of information...

And... I've just copied the class from an example, and called Register()...

I'm trying to automate Visual Studio, in most cases the program flow works perfectly.

In some other cases it fails during calls to the Visual studio DTE...

In the manual from the manufacturer of the software I'm using they state that I should implement that COM Message Filter and they explain how to do it... Even they provide a sample that I've pasted directly into my code...

Anyone can see what's wrong given the message?

Should I add any dependency or similar thing into my project to get this working?

Being ultra-novice in C# I can't see where to search now...

And I truly would like not to add wait timers everywhere...

Thank you very much for your time and help.
www.robotecnik.com[^] - robots, CNC and PLC programming

SuggestionRe: Implementing a COM Message Filter, it always fails... Pin
Richard Deeming21-Sep-17 6:14
mveRichard Deeming21-Sep-17 6:14 
GeneralRe: Implementing a COM Message Filter, it always fails... Pin
Joan M21-Sep-17 6:21
professionalJoan M21-Sep-17 6:21 
GeneralRe: Implementing a COM Message Filter, it always fails... Pin
Richard Deeming21-Sep-17 6:37
mveRichard Deeming21-Sep-17 6:37 
GeneralRe: Implementing a COM Message Filter, it always fails... Pin
Joan M21-Sep-17 7:26
professionalJoan M21-Sep-17 7:26 
QuestionEntity Framework Questions - Round 1 Pin
Kevin Marois21-Sep-17 4:11
professionalKevin Marois21-Sep-17 4:11 
AnswerRe: Entity Framework Questions - Round 1 Pin
Nathan Minier21-Sep-17 4:46
professionalNathan Minier21-Sep-17 4:46 
GeneralRe: Entity Framework Questions - Round 1 Pin
Kevin Marois21-Sep-17 4:48
professionalKevin Marois21-Sep-17 4:48 
GeneralRe: Entity Framework Questions - Round 1 Pin
Nathan Minier21-Sep-17 5:19
professionalNathan Minier21-Sep-17 5:19 
AnswerRe: Entity Framework Questions - Round 1 Pin
C. David Johnson6-Oct-17 7:15
C. David Johnson6-Oct-17 7:15 
GeneralRe: Entity Framework Questions - Round 1 Pin
Nathan Minier10-Oct-17 2:34
professionalNathan Minier10-Oct-17 2:34 
AnswerRe: Entity Framework Questions - Round 1 Pin
Gerry Schmitz21-Sep-17 13:05
mveGerry Schmitz21-Sep-17 13:05 
QuestionHow to save an excel file via network ? Pin
Member 1342184321-Sep-17 3:06
Member 1342184321-Sep-17 3:06 
GeneralRe: How to save an excel file via network ? Pin
Richard MacCutchan21-Sep-17 3:17
mveRichard MacCutchan21-Sep-17 3:17 
AnswerRe: How to save an excel file via network ? Pin
Eddy Vluggen21-Sep-17 6:28
professionalEddy Vluggen21-Sep-17 6:28 
AnswerRe: How to save an excel file via network ? Pin
Gerry Schmitz21-Sep-17 13:06
mveGerry Schmitz21-Sep-17 13:06 
Questionperformance counter in visual studio 217 C# Pin
AMMAR ALNAJIM20-Sep-17 20:41
AMMAR ALNAJIM20-Sep-17 20:41 
AnswerRe: performance counter in visual studio 217 C# Pin
Pete O'Hanlon20-Sep-17 21:10
mvePete O'Hanlon20-Sep-17 21:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.