PDA

View Full Version : پیغام خطای ApplicationClass



nooshin609
چهارشنبه 22 خرداد 1392, 09:33 صبح
با سلام
پیغام خطای Interop type 'Microsoft.Office.Interop.Word.ApplicationClass' cannot be embedded
یعنی چی؟؟؟؟؟؟؟؟؟؟
البته dll مربوطه رو تو refrenceها add کردما!!!!
با تشکر

nooshin609
چهارشنبه 22 خرداد 1392, 11:11 صبح
ممنون
copy local غیر فعاله
Embeded Introp Types خودش true هست

alexmcse
چهارشنبه 22 خرداد 1392, 11:31 صبح
ببینید دی ال ال در پوشه دیباگ پروژه قرار دارد؟
این را تست کنید ببینید مشکل حل میشود
یکبار دی ال ال را به پوشه دیباگ کپی کنید سپس به رفرنس ها د ی ال ال را در پوشه دیباگ اضافه کنید

nooshin609
چهارشنبه 22 خرداد 1392, 12:15 عصر
بازم حل نشد:ناراحت: :ناراحت: :ناراحت:

tooraj_azizi_1035
چهارشنبه 22 خرداد 1392, 12:21 عصر
شما Target Framework تون رو چند ست شده؟ 4 یا 3 یا 2 ..
کدتون رو هم بگذارید.

nooshin609
چهارشنبه 22 خرداد 1392, 12:33 عصر
میشه راهنمایی کنین Target Framework از کجا ببینم؟!!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Collections;
using System.Threading;
using Microsoft.Office.Interop.Word;

namespace wrd
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int GetNoOfPagesDOC(string FileName)
{
int num = 0;
object fileName = FileName;
object readOnly = false;
object isVisible = true;
object objDNS = Word.WdSaveOptions.wdDoNotSaveChanges;
try
{
Word.ApplicationClass WordApp = new Word.ApplicationClass();

// give any file name of your choice.

// the way to handle parameters you don't



care

about in .NET
object missing = System.



Reflection

.Missing.Value;

// Make word visible, so you can see what's happening
//WordApp.Visible = true;
// Open the document that was chosen by the dialog

Word.Document aDoc = WordApp.Documents.Open(ref fileName,
ref missing, ref readOnly, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref isVisible,
ref missing, ref missing, ref missing, ref missing);
Word.WdStatistic stat = Word.WdStatistic.wdStatisticPages;
num = aDoc.ComputeStatistics(stat, ref missing);
WordApp.Quit(ref objDNS, ref missing, ref missing);
aDoc = null;
WordApp = null;
GC.Collect();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return num;

}

private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}

private void button2_Click(object sender, System.EventArgs e)
{
MessageBox.Show(GetNoOfPagesDOC(textBox1.Text).ToS tring());
}
}
}

tooraj_azizi_1035
چهارشنبه 22 خرداد 1392, 12:49 عصر
راست کلیک روی پروژه و انتخاب Properties و Target Framework.
اینو تست کن:

Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();

nooshin609
چهارشنبه 22 خرداد 1392, 13:10 عصر
target روی 4
کدی که دادین
الان فقط واسه word پیغام not fount میده ،ایا به dll ربط داره یا کتابخونه ی دیگه ای میخاد؟؟