protected override byte[] GenerateCode(string inputFileName, string inputFileContent) { VSLangProj.Reference reference = _project.VSLangProj_References.Find("System.Drawing"); if (reference != null) { reference.Remove(); } string spotGraphics = "Microsoft.SPOT.Graphics"; reference = _project.VSLangProj_References.Find(spotGraphics); if (reference == null) { _project.VSLangProj_References.Add(spotGraphics); } MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); string inputFileNameWithoutExtension = Path.GetFileNameWithoutExtension(inputFileName); Assembly tasks = null; foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { if (string.Compare(asm.GetName().Name, "Microsoft.SPOT.Tasks", true) == 0) { if (asm.GetName().Version.ToString(2) == new Version(_project.GetTargetFrameworkProperty().TrimStart('v')).ToString(2)) { tasks = asm; break; } } } if (tasks == null) { throw new Exception("Microsoft.SPOT.Tasks.dll is not loaded!"); } Type typ = tasks.GetType("Microsoft.SPOT.Tasks.ProcessResourceFiles"); if (typ != null) { object processResourceFiles = typ.GetConstructor(new Type[] {}).Invoke(null); typ.GetProperty("StronglyTypedClassName").SetValue(processResourceFiles, inputFileNameWithoutExtension, null); typ.GetProperty("StronglyTypedNamespace").SetValue(processResourceFiles, GetResourcesNamespace(), null); typ.GetProperty("GenerateNestedEnums").SetValue(processResourceFiles, m_fNestedEnums, null); typ.GetProperty("GenerateInternalClass").SetValue(processResourceFiles, m_fInternal, null); typ.GetProperty("IsMscorlib").SetValue(processResourceFiles, m_fMscorlib, null); string resourceName = (string)typ.GetProperty("StronglyTypedNamespace").GetValue(processResourceFiles, null); if (string.IsNullOrEmpty(resourceName)) { resourceName = inputFileNameWithoutExtension; } else { resourceName = string.Format("{0}.{1}", resourceName, inputFileNameWithoutExtension); } typ.GetMethod("CreateStronglyTypedResources").Invoke(processResourceFiles, new object[] { inputFileName, this.CodeProvider, writer, resourceName }); } return(base.StreamToBytes(stream)); }