I am trying to open an old project , but when I open(Form1.cs) it give me an error on particular forms designer view that
The parameter is incorrect
Heres the call stack
at System.Drawing.Icon.Initialize(Int32 width, Int32 height)
at System.Drawing.Icon..ctor(Stream stream, Int32 width, Int32 height)
at System.Drawing.Icon..ctor(Stream stream)
at System.Drawing.IconConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
at System.Resources.ResXDataNode.GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver)
at System.Resources.ResXDataNode.GetValue(ITypeResolutionService typeResolver)
at System.Resources.ResXResourceReader.ParseDataNode(XmlTextReader reader, Boolean isMetaData)
at System.Resources.ResXResourceReader.ParseXml(XmlTextReader reader)
When I try to open Form1.resx file it gave me an error:
resource '$this.icon' could not be instantiated
I researched at it says it because it might be on .NET 2.0, but mine is in .NET 3.5 and its on VS2008.
So , can any one tell me hwo to fix this issue, as its old one and we cannot recreate it.
Thanks
Related
I'm writting a C# application which use one of the dll written in C++ as reference. I can use that dll namespace and my project compiles fine. However when I run it I keep getting error in one of the line where I assign a property its value. The exception error I got was the following:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
2013-06-03 12:26:32 - Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))
2013-06-03 12:26:32 - at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
2013-06-03 12:26:32 - at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
2013-06-03 12:26:32 - at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
2013-06-03 12:26:32 - at sstObjTapLib._DsstObjTap.set_CapCode(String )
2013-06-03 12:26:32 - at hpOutput.CTapPagerCom.MessageLoop() in c:\shs\Arial 8.1\XmarkClient\hpOutput\CTapPagerCom.cs:line 225
I initiated the dll object using the following code:
m_ctlTap = new sstObjTapLib.ctlTap();
Below are the three screenshots:
The properties of the DLL I use
The object browser of the dll I use
A breakpoint that shows where the exception occurs.
Looking at the stack error above, it seems that .NET is trying to call some method that does not exist, but I'm just setting a property value. Can somebody point me in the right direction or what I might have missed?
A noted point: While in debugging, I'm looking at my loaded module view, however I don't see this dll name one in the list of my loaded module.
I'm not sure why but the computer I worked with had this same dll installed. I know this by viewing it using the third party tool called RegDllView .
So I went in, unregister the dll I was using, verify it is also gone from the registry and then re-register it again. Clean out my project and recompile everything, and got the exact code to work.
Looking at what I did I think for some reason the application did not recognize the GUID supplied to point to the proper COM.
I've found StackOverflow quite a helpful reference in the past, and now that I've come up against an obstacle of my own, thought I'd try posting here.
My issue is that whenever my game attempts to load a SoundEffect file, it crashes with an InvalidOperationException (detail message: an unexpected error has occurred). This game is being written on the XNA 4.0 framework, in C# with Visual Studio 2010 express as my IDE. The sound effects being loaded are all .wav files, and are added into the game's Content project.
I've checked the board and tried the following suggestions:
Confirm content.rootDirectory it set - it is set to "Content"
Confirm content.load<> is accessing the resource via the correct path. Using reflection, I got the current directory for the application, and then used the rootdirectory + the path it was trying to access. The file definitely exists, is accessible, and is in that location.
Ensure ContentManager content is not null - confirmed using debugging, and that would throw a different exception anyway.
Confirm WAV is in 8 or 16 bit PCM. Confirmed.
Possible header corruption? This error occurs on any and all sound effects I attempt to load, so it is not a header issue pertaining to one file.
Oddly enough, this error seems to have come out of nowhere. It was working without problem for the past week, today its freaking out - and I haven't made any changes that would affect the content load process.
Here's the code throwing the error:
public void LoadSoundEffect(ContentManager content, String assetPath)
{
if (content != null && String.IsNullOrEmpty(assetPath) == false)
{
// This next line throws the exception.
SoundEffect effectLoader = content.Load<SoundEffect>(assetPath);
soundLibrary.Add(assetPath, effectLoader);
}
}
Here's the stacktrace:
at Microsoft.Xna.Framework.Helpers.ThrowExceptionFromErrorCode(Int32 error)
at Microsoft.Xna.Framework.Audio.SoundEffect.AllocateFormatAndData(Byte[] format, Byte[] > data, Int32 offset, Int32 count)
at Microsoft.Xna.Framework.Audio.SoundEffect.Create(Byte[] format, Byte[] data, Int32
offset, Int32 count, Int32 loopStart, Int32 loopLength, TimeSpan duration)
at Microsoft.Xna.Framework.Audio.SoundEffect..ctor(Byte[] format, Byte[] data, Int32
loopStart, Int32 loopLength, TimeSpan duration)
at Microsoft.Xna.Framework.Content.SoundEffectReader.Read(ContentReader input,
SoundEffect existingInstance)
at Microsoft.Xna.Framework.Content.ContentReader.InvokeReader[T](ContentTypeReader
reader, Object existingInstance)
at Microsoft.Xna.Framework.Content.ContentReader.ReadObjectInternal[T](Object
existingInstance)
at Microsoft.Xna.Framework.Content.ContentReader.ReadObjectT
at Microsoft.Xna.Framework.Content.ContentReader.ReadAssetT
at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName,
Action`1 recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
at SerializableDataTypes.AudioManager.LoadSoundEffect(ContentManager content, String
assetPath) in C:\Users\Mike\Documents\Visual Studio 2010\Projects\Res Judicata
Chapter1\SerializableDataTypes\Script Elements\AudioManager.cs:line 78
Thanks in advance for any help you can offer - I'm completely stumped on this, and it's a really frustrating error.
Just for curiosities sake, can you attempt loading your sound effect slightly differently.
SoundEffect effect = content.Load<SoundEffect>(String.Format(#"{0}", soundEffectPath))
I have had issues in the past loading certain content types when not using a string literal.
I have a DataGridView that displays a list of MMS Messages. To differentiate between sent and received, I put a right arrow and left arrow in a column. Our customer loved it, but wants the right arrow to be green for even more clarity, especially in international environments.
I took the right arrow and opened it in Visual Studio 2003 (I am using VS2010 for writing the application). I recolored the icon and it looked great, however when I went to display the containing Control, I get the following error:
The following exception occurred in the DataGridView:
System.ArgumentException: Parameter is not valid.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.ImageConverter.convertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.Windows.Forms.Formatter.FormatObjectInternal(Object value, Type targetType, TypeConverter sourceConverter, TypeConverter targetConverter, String formatString, IFormatProvider formatInfo, Object formattedNullValue, Object dataSourceNullValue)
at System.Windows.Forms.DataGridViewCell.GetFormattedValue(Object value, Int32 rowIndex, DataGridViewCellStyle& cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
To replace this default dialog please handle the DataError event.
When I create the DataTable to be populated with the data, I use this on the column that will have the icon
dt.Columns.Add(sDirection);
dt.Columns[sDirection].DataType = typeof(Byte[]);
When I add the data to the rows, I have a method to convert the Icon.
internal static Byte[] ConvertIconToByteArray(Icon pIcon) {
MemoryStream ms = new MemoryStream();
pIcon.Save(ms);
return (ms.GetBuffer());
}
And I add the DataTable to the DataGridView with
grdMMSList.DataSource = dt.DefaultView;
(Method calls removed from the above code for clarity)
I followed through in the debugger, and setting the DefaultView as the DataSource is where the error is getting thrown. I tried placing it in a try/catch block so I could see the Exception, but it doesn't trigger the catch.
Just a few other bits of information:
- The icon is stored as a Resource and is called by Properties.Resources.RightArrow
- After changing the colors, I just Save the file in VS2003, nothing with a Save As. The file still shows up as an Icon everywhere.
- Back in VS2010, the Resource File does have the new color scheme and renders properly there.
Thank you in advance for any help you can provide.
I would not edit the images this way. If you want a valid set of arrows that are all supported for addition into a DataGridView, so to the directory
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\VS2010ImageLibrary\1033
here you will find a .zip file. Unzip it.
Then you will find varios subdirectories with loads of MS icon and images etc. Navigate to
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\VS2010ImageLibrary\1033
\VS2010ImageLibrary\VS2010ImageLibrary\Objects\png_format\WinVista
here you will find all different kinds of arrows in all different colours. My advice is use these, not your bitmap edits to existing files.
I hope this helps.
We have an application that we need to begin testing and developing in Windows 7 environment. It works fine compiling under WinXP in VS2008, no problems. However when I went to compile it on a windows 7 machine using VS2008 today I get the following error:
Error 12 The "GenerateResource" task failed unexpectedly.
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(MemoryStream stream)
at System.Drawing.Image.System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at System.Resources.ResourceWriter.WriteValue(ResourceTypeCode typeCode, Object value, BinaryWriter writer, IFormatter objFormatter)
at System.Resources.ResourceWriter.Generate()
at System.Resources.ResourceWriter.Dispose(Boolean disposing)
at System.Resources.ResourceWriter.Close()
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(IResourceWriter writer)
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(String filename)
at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, List`1 inputs, List`1 outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, List`1 inputs, List`1 outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
I cannot for the life of me run this one down. I have visited the msdn forums and find that it is an issue for a lot of people, but no consistent solution has been provided by MS or anyone else.
Has anyone seen this before and fixed it? Please advise is needed!
Thanks
I compiled using the command line msbuild and that identified the problem location.
It was a resx file in a class which had one unused image in it. I removed that and all was good again. Can build fine now.
After hours of troubleshooting, I opened and built the project using the VS 2010 command line prompt using MSBUILD "my solution file path here". This provided a more visible sequence of build events, and I found my project was failing just after it compiled form 16. The forms compiling appeared to be going in order of the objects in the solution explorer. So I checked the next form and found it contained a picture box. I also checked the form after that one and found I could not open the designer without errors(object reference not set to instance of object). So apparently, the problem was now two-fold.
To resolve I had to remove the picture box object from the first form I identified as problematic (it was not being used any way) as it appeared to be corrupted. I found the second form with the null reference exception was using a user control. The code for the constructor of the user control was attempting to pass an object to a container before calling InitializeComponent(). This created the null reference since the container hadn't event been created in InitializeComponent when the problematic code was called.
After resolving the issues in the above paragraph my solution compiled under Windows 7.
There is a GDI update for Windows 7, I think, if I'm not mistaken. Maybe that will solve the issue. Does your solution build using Msbuild on the commsnd line?
Do you use TIFF images in your app?
Some time ago, I also had a problem with TIFF images as part of reports that wouldn't compile under Win7 x64 although it compiled like a charm under Vista x86. The error message also involved GDI+. I saved the images under a different format (PNG) and the problem vanished.
At the time (around March 2011), I first ensured that my Windows was up-to-date but it didn't solve the problem. So maybe there is such an update as mentionned by Erik but it didn't come through Windows Update back then (Maybe it's newer).
Delete the resources from the resource manager (right click on each and delete) then add them back. for me it solve the problem.
i had same problem.
i just used msbuild myProject.sln command and it fixed and built successfully with no errors! now i can manually build my solution.
no need to reAdding my resources
How might I host a WinForms Control (or WPF Window for that matter) created in a different AppDomain on a form created in my application?
I'm trying to create a composite UI application that is a featureless shell/host for plugins, where those plugins run entirely in their own app domains, so I want to be able to get UserControl objects from those plugins to be "hosted" in some sort of container control on the host process's main form.
I thought I'd cracked it, but because conversations between appdomains involve MarshallByRefObject proxies, I can't take my first prototype approach of:
shellForm.Panel1.Controls.Add(proxyObjectForUserControlInOtherAssembly);
I've posted the exception I got from this at the end of the question.
I did have a go at getting the control directly:
var ctl = Control.FromHandle(proxyObjectForUserControlInOtherAssembly.Handle);
shellForm.Panel1.Controls.Add(ctl);
This gave predictable results. I got the hWnd okay, but Control.FromHandle() returned null. Presumably because the handle was created on a different appdomain.
I'd very much appreciate a poke in the right direction if I'm hopelessly off track with this. :)
Many thanks in advance.
System.Runtime.Remoting.RemotingException was unhandled by user code
Message=Remoting cannot find field 'parent' on type 'System.Windows.Forms.Control'.
Source=mscorlib
StackTrace:
at System.Object.GetFieldInfo(String typeName, String fieldName)
at System.Object.FieldGetter(String typeName, String fieldName, Object& val)
at System.Object.FieldGetter(String typeName, String fieldName, Object& val)
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at AppDomainTest.Shell.Form1.Display(Control control) in c:\temp\AppDomainTest\AppDomainTest\AppDomainTest.Shell\Form1.cs:line 24
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
InnerException:
I have been helpfully pointed in one possible direction by a colleague: .NET Add-in Framework
The key point from that page for my purposes is as follows:
The assemblies for these segments are
not required to be in the same
application domain. You can load an
add-in into its own new application
domain, into an existing application
domain, or even into the host's
application domain. You can load
multiple add-ins into the same
application domain, which enables the
add-ins to share resources and
security contexts.